Jump to content

Paulqvz

Members
  • Posts

    29
  • Joined

  • Last visited

Paulqvz's Achievements

Member

Member (2/5)

0

Reputation

  1. Good day I have a label script where i have to print labels. the problem i have is that it is not returning the right amount of rows dependant on qty column. $sql="SELECT so.`name` AS so_name, sol.`name` AS sol_name,sol.`quantity` AS sol_quantity,`delivery_date`,DATE_ADD(`delivery_date`, INTERVAL 10 DAY) AS used_day FROM `sales_orders` so INNER JOIN `sales_order_lines` sol ON so.id = sol.`sales_orders_id` WHERE sol.`parent_id` IS NULL AND so.id = '$id'"; $result = mysqli_query($connect, $sql); $degree = "STORAGE: KEEP REFRIGERATED BELOW 5`C"; //var_dump($degree); while($row = mysqli_fetch_array($result)) { //$so_name = $row['so_name']; $sol_name[] = $row['sol_name']; $sol_quantity[] = $row['sol_quantity']; $sol_quantityy = $row['sol_quantity']; $delivery_date[] = $row['delivery_date']; $used_day[] = $row['used_day']; } foreach($sol_quantity as $index => $value) { for($i=1; $i <=$value;$i++) { $text = sprintf( "%s\n%s %s\n%s %s\n%s\n%s", "$sol_name[$index]","<br>", 'Delivery Date', "<br>", 'Use By Date', "<br>", "$delivery_date[$index]","<br>", "$used_day[$index]","<br>", 'PRODUCT OF SOUTH AFRICA',"<br>", "{$degree}" ); $sol_quantity[] for all three products here is 3 . It is returning CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07 Instead of CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 CARROT & POTATO MIX Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 POTATO Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07 ONION Delivery Date Use By Date 2021-09-07
  2. foreach ($objPHPExcel->getActiveSheet() as $worksheet) { exactly why i need guidiance . it one sheet with lotsa data all rows filled int till g500 but i know that word is somewhere in column A so i want to search Column A for that word.
  3. does getActiveSheet() return multiple values? - yes - not to be forward - but you keep asking questions but never give answers or point in a direction, are there any other people on this forum that actually code in php?
  4. but it does not return anything - says there is nothing although it is in a20?
  5. oreach is only for multiple values. Does getActiveSheet() return multiple values? how else will i search the excell for the string - 'INACTIVE MEMBERS' and return in what cell it is
  6. got this right with $q = count(glob("$directory/*")) == 0; if ($q) { echo "the folder is empty"; } else {
  7. this pasrt of the code is where i am trying to search for the string //get INACTIVE MEMBERS $foundInCells = array(); $searchValue = 'INACTIVE MEMBERS'; foreach ($objPHPExcel->getActiveSheet() as $worksheet) { $ws = $worksheet->getTitle(); foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(true); foreach ($cellIterator as $cell) { if ($cell->getValue() == $searchValue) { $foundInCells[] = $ws . '!' . $cell->getCoordinate(); } } } } echo "<br>"; echo "<br>"; echo "this is where - - "; var_dump($foundInCells); echo "<br>"; echo "<br>";
  8. Hi there I have started using php excell and getting most of it right. But i am struggling to search active sheet and return what cell the string is in. below is my code. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); set_time_limit(0); $directory = "/var/www/html/csvex/xls/"; $formatdirectory = "/var/www/html/csvex/toformat/"; $finishedformatdirectory = "/var/www/html/csvex/formatted/"; $savanadirectory = "/var/www/html/iretire/files/upload/1/"; $main = "/var/www/html/csvex/"; $files = scandir($directory, SCANDIR_SORT_DESCENDING); $newest_file = $files[0]; echo $newest_file; echo "<br>"; $oldfile = $directory.$newest_file; $newfile = $formatdirectory.$newest_file; $changedfile = $finishedformatdirectory.$newest_file; $crmfile = $savanadirectory.$newest_file; echo $oldfile; echo "<br>"; echo $newfile; echo "<br>"; if( !rename($oldfile, $newfile) ) { echo "File can't be moved!"; } else { echo "File has been moved!"; } //format the file date_default_timezone_set('Europe/London'); set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/'); include 'PHPExcel/IOFactory.php'; $fileType = 'Excel5'; $fileName = $newfile; // Read the file $objReader = PHPExcel_IOFactory::createReader($fileType); $objPHPExcel = $objReader->load($fileName); //change font $objPHPExcel->getActiveSheet()->getStyle('a1:a6')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); $objPHPExcel->getActiveSheet()->getStyle('a6:aa6')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); $objPHPExcel->getActiveSheet()->getStyle('n16:aa16')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); //get INACTIVE MEMBERS $foundInCells = array(); $searchValue = 'INACTIVE MEMBERS'; foreach ($objPHPExcel->getActiveSheet() as $worksheet) { $ws = $worksheet->getTitle(); foreach ($worksheet->getRowIterator() as $row) { $cellIterator = $row->getCellIterator(); $cellIterator->setIterateOnlyExistingCells(true); foreach ($cellIterator as $cell) { if ($cell->getValue() == $searchValue) { $foundInCells[] = $ws . '!' . $cell->getCoordinate(); } } } } echo "<br>"; echo "<br>"; echo "this is where - - "; var_dump($foundInCells); echo "<br>"; echo "<br>"; // $objPHPExcel->getActiveSheet()->getStyle('a20')->applyFromArray( $styleArray = array( 'font' => array( 'bold' => true ) ) ); its located at //Get inactive members. another one i am struggling with is to see if file exists if not then do nothing if it does run the code.
  9. <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); set_time_limit(0); $directory = "/var/www/html/default/csvex/xls/"; $formatdirectory = "/var/www/html/default/csvex/toformat/"; $finishedformatdirectory = "/var/www/html/default/csvex/formatted/"; $files = scandir($directory, SCANDIR_SORT_DESCENDING); $newest_file = $files[0]; echo $newest_file; echo "<br>"; $oldfile = $directory.$newest_file; $newfile = $formatdirectory.$newest_file; $changedfile = $finishedformatdirectory.$newest_file; echo $oldfile; echo "<br>"; echo $newfile; echo "<br>"; if( !rename($oldfile, $newfile) ) { echo "File can't be moved!"; } else { echo "File has been moved!"; } chmod($newfile, 755); //format the file date_default_timezone_set('Europe/London'); set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/'); include 'PHPExcel/IOFactory.php'; $fileType = 'Excel5'; $fileName = $newfile; // Read the file $objReader = PHPExcel_IOFactory::createReader($fileType); $objPHPExcel = $objReader->load($fileName); $objPHPExcel->getActiveSheet()->getStyle('d1:d9')->applyFromArray( array('fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('argb' => 'ffffffff') ), ) ); // Change the file $objPHPExcel->setActiveSheetIndex(0) ->setCellValue('d1', 'booya') ->setCellValue('d9', 'ddddddddddddddddddd!'); // Write the file $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType); $objWriter->save($fileName); ?>
  10. hi yes - here is the code. <?php error_reporting(E_ALL); date_default_timezone_set('Europe/London'); set_include_path(get_include_path() . PATH_SEPARATOR . './Classes/'); include 'Classes/PHPExcel/IOFactory.php'; require_once('Classes/PHPExcel.php'); $phpExcel = PHPExcel_IOFactory::load('/var/www/html/default/csvex/xls/aaa.xls'); function cellColor($cells,$color){ global $objPHPExcel; $objPHPExcel->getActiveSheet()->getStyle($cells)->getFill()->applyFromArray(array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'startcolor' => array( 'rgb' => $color ) )); } cellColor('B5', 'F28A8C'); cellColor('G5', 'F28A8C'); cellColor('A7:I7', 'F28A8C'); cellColor('A17:I17', 'F28A8C'); cellColor('A30:Z30', 'F28A8C'); $writer->save('baaa.xls');
  11. Good day all. I am looking for guidence. I am using phpexcell to format an excell file. all working 100% What should i be looking to do when i want to edit and format multiple files in a directory. about 200 excell documents all the same and with same formatting? Found this code for reading, but lets say row c3:i3 i want bold and size 14 in all the excell files . . . $path = "..."; ///the folder path $theFilePath = ""; $theFileName = glob ($path . "*.xls"); //Read more than one file here for($j = 0; $j< count($theFileName); $j++) { $theFilePath = $theFileName[$j]; $excel = new Spreadsheet_Excel_Reader(); $excel->setOutputEncoding('CP1251'); $excel->setUTFEncoder('mb_convert_encoding'); error_reporting(E_ALL ^ E_NOTICE); //echo $theFileName[$j];; echo "<br />"; echo $theFilePath; echo "<br />"; $excel->read($theFilePath); . . .// Do what u want display here }
  12. seriously - dumb it down a bit. relax and read the question again. Key length is the same. that is the c# they have given me, and this is the php i am trying. Si in stead om rambling just none helpful links and none useful comments, rather start of by helping by explaining how to get that c# code over to des encryption with either hex or $iv = "0112233445566778"; Not being disrespectful or anything else, but if you cant help with that please do not reply again as it wastes time and space. I have spent a whole freaking day trying to get that c# being the same as php and need real assistance
  13. well thats why i am here - trying to understand this all. i just need des - and read somewhere to get the same as c# i should remove padding? so please explain the pkcs padding? this is the code i am now busy with. with the correct key on my side $iv = $key; $pass_enc = $textToEncrypt; $block = mcrypt_get_block_size('des', 'cbc'); $pad = $block - (strlen($pass_enc) % $block); $pass_enc .= str_repeat(chr($pad), $pad); $pass_enc = mcrypt_encrypt(MCRYPT_DES, $key, $pass_enc, MCRYPT_MODE_CBC, $iv); $pass_enc1 = base64_encode ($pass_enc); echo $pass_enc1." -- "; output 4Oz0+7kX3naomfZpjW7y+g== -- expected- WfRb+Vugfc1cbJNfXKL6bw==
  14. encrypted output=bimbcVvpJ/NBxllxxCsW+w== decrypted output=5512065314089 expected- WfRb+Vugfc1cbJNfXKL6bw== if i change the key i get the same, but not the same in c#- so c# and php outputs differ
  15. i could not give the same key as it is used in company and would be dangerous. I also do not have c#. All i got was this is how we do the encryption and decryption. I am litterly stuck.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.