Is it posibble to save existing file with out creating the writer object in PHPExcel?
$filename = 'test.xlsx';
$phpExcel = PHPExcel_IOFactory::load($filename);
$phpExcel->save($filename);
I am in searching to find a solution to convert the .xlsx(Excel) file into pdf files.
require_once('phpExcel/PHPExcel/IOFactory.php');
require_once('phpexcel/PHPExcel.php');
$fileType = 'Excel5';
$fileName = 'testing.xlsx';
$outputFileType = 'PDF';
$outputFileName = 'test.pdf';
$objPHPExcel = PHPExcel_IOFactory::load($fileName);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $outputFileType);
$objWriter->writeAllSheets();
$objWriter->save($outputFileName);
I used this above code,but is not working. If any can an Idea, please help me
when i reading xls or xlsx using PHPExcel it leads to a browser message The connection was reset
but when i read csv file it works fine.
my code is
/* checking extension*/
if($ext=="xls")
{
$objReader = new PHPExcel_Reader_Excel5();
}
else if($ext=="csv")
$objReader = new PHPExcel_Reader_CSV();
else
$objReader = new PHPExcel_Reader_Excel2007();
/* ........end checking .............. */
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($name);
I already have a document of excel and I want to use php to insert an image to that excel.
Is it possible to do that? How to implement it (code)?
Thanks,
$fileType = 'Excel2007';
$fileName = 'test.xlsx';
// Load the workbook
$objPHPExcelReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objPHPExcelReader->load($fileName);
// Add an image to the worksheet
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('My Image');
$objDrawing->setDescription('The Image that I am inserting');
$objDrawing->setPath('./images/myImage.png');
$objDrawing->setCoordinates('B2');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
// Save the workbook
$objPHPExcelWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,$fileType);
$objPHPExcelWriter->save($fileName);
I need to aggregate 4 CSV files into a single, Excel workbook using PHPExcel.
Working on a single CSV file and a mono-spreadsheet workbook all works fine.
Using more than one CSV, I'm unable to get each CSV file into a seperate sheet.
How can I achieve this using PHPExcel?
There is an example of this in the Documentation/Examples/Readers directory in the SVN repository for PHPEXcel: It's Example #13
include 'PHPExcel/IOFactory.php';
$inputFileType = 'CSV';
$inputFileNames = array('./example1.csv','./example2.csv','./example3.csv','./example4.csv');
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$inputFileName = array_shift($inputFileNames);
$objPHPExcel = $objReader->load($inputFileName);
$objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME));
foreach($inputFileNames as $sheet => $inputFileName) {
$objReader->setSheetIndex($sheet+1);
$objReader->loadIntoExisting($inputFileName,$objPHPExcel);
$objPHPExcel->getActiveSheet()->setTitle(pathinfo($inputFileName,PATHINFO_BASENAME));
}
$loadedSheetNames = $objPHPExcel->getSheetNames();
foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) {
$objPHPExcel->setActiveSheetIndexByName($loadedSheetName);
echo $loadedSheetName,PHP_EOL;
$sheetData = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
var_dump($sheetData);
echo PHP_EOL;
}
You didn't specify exactly where the problem is...
For multiple worksheet excel file proceed as following:
Load CSV file
Create new worksheet
Write CSV to new worksheet
Go to 1
From docs:
If you need to create more worksheets in the workbook, here is how:
$objWorksheet1 = $objPHPExcel->createSheet();
$objWorksheet1->setTitle('Another sheet');
To set active worksheet:
$objWorksheet1->setActiveSheetIndex($index);