2017-11-14 12 views
-1

2つの異なるExcelファイル(ブック)があり、1つに2つのシートがあり、もう1つが3つあり、PHPのExcelライブラリを使用してPHPコードで1つのファイルにまとめられます1枚のファイルを5枚にすることができますが、すべてのデータ&テーブルは問題ありませんが、円グラフはありません&グラフ(その空白)。 ブックとグラフを組み合わせるにはどうすればいいですか?&グラフ。Excelで複数のワークブックをマージする方法

include ("PHPExcel.php"); 

$inputFileType1 = 'Excel2007'; 
$inputFileName1 = 'a.xlsx'; 
$inputFileType2 = 'Excel2007'; 
$inputFileName2 = 'b.xlsx'; 
$outputFileType = 'Excel2007'; 
$outputFileName = 'c.xlsx'; 

// Load the first workbook (an xlsx file) 
$objPHPExcelReader1 = PHPExcel_IOFactory::createReader($inputFileType1); 
$objPHPExcelReader1->setIncludeCharts(TRUE); 

$objPHPExcel1 = $objPHPExcelReader1->load($inputFileName1); 

// Load the second workbook (an xls file) 
$objPHPExcelReader2 = PHPExcel_IOFactory::createReader($inputFileType2); 
$objPHPExcelReader2->setIncludeCharts(TRUE); 
$objPHPExcel2 = $objPHPExcelReader2->load($inputFileName2); 

// Merge the second workbook into the first 
$objPHPExcel2->getActiveSheet()->setTitle('Unique worksheet name'); 
$objPHPExcel1->addExternalSheet($objPHPExcel2->getActiveSheet()); 

// Save the merged workbook under a new name (could save under the original 
name) 
// as an xls file 
$objPHPExcelWriter = PHPExcel_IOFactory::createWriter($objPHPExcel1,$outputFileType); 
$objPHPExcelWriter->save($outputFileName); 
+0

重複の可能性:Excel2007をする必要がありますので、私が持っているhttps://stackoverflow.com/questions/11545974/merge-excel-files-using-php – whoami

答えて

0
$inputFileType1 = 'Excel2007'; 
$inputFileName1 = 'inputData1.xlsx'; 
$inputFileType2 = 'Excel5'; 
$inputFileName2 = 'inputData2.xls'; 
$outputFileType = 'Excel5'; 
$outputFileName = 'outputData.xls'; 

// Load the first workbook (an xlsx file) 
$objPHPExcelReader1 = PHPExcel_IOFactory::createReader($inputFileType1); 
$objPHPExcel1 = $objPHPExcelReader1->load($inputFileName1); 

// Load the second workbook (an xls file) 
$objPHPExcelReader2 = PHPExcel_IOFactory::createReader($inputFileType2); 
$objPHPExcel2 = $objPHPExcelReader2->load($inputFileName2); 

// Merge the second workbook into the first 
$objPHPExcel2->getActiveSheet()->setTitle('Unique worksheet name'); 
$objPHPExcel1->addExternalSheet($objPHPExcel2->getActiveSheet()); 

// Save the merged workbook under a new name (could save under the original name) 
// as an xls file 
$objPHPExcelWriter = PHPExcel_IOFactory::createWriter($objPHPExcel1,$outputFileType); 
$objPHPExcelWriter->save($outputFileName); 
+0

実際のファイルの両方が.xlsxの形式でありますファイルタイプで使用されていると思いますが、私はこれを試しました、同じ結果はグラフとグラフなし – Sooraz

関連する問題