I have a php page using a Excel.Application to duplicate a sheet containing some data and an embedded chart.
the code is this:
$Excel=new COM("Excel.application");
$workbook=$Excel->Workbooks->Open($fileName);
//alternative 1
$workbook->Worksheets("Sheet1")->Copy(NULL,$workbook->Worksheets("Sheet2"));
//alternative 2
$added=$workbook->Worksheets->Add();
$added->Name=$destName;
$workbook->Worksheets($sourceName)->Range("A1:Z100")->Copy($added->Range("A1"));
$workbook->SaveAs($fileNameDest);
The result is that the data and the formula are correctly copied and formatted, but the chart in the sheet1 is not copied in the sheet2. No error, no exception, but also no chart for both code alternatives.
Can anyone help me copying this sheet... fully?
Thanks!
Print a chart without worksheet data If the chart is on a separate chart sheet, click the chart sheet tab. , and then click Print. By default, Selected Chart is selected under Print what. You can click Preview to see how the chart will look on the printed page.
Select the Excel chart (single click) and then right click to choose Copy. Move to a different location in the same worksheet or add a new worksheet and then right click and choose Paste. This gives you an exact copy of the chart so it is linked to the original data range and has the same formatting.
In Microsoft Excel and other spreadsheet programs, there are two types of charts: an embedded chart and chart sheet. An embedded chart is a chart object that can be inserted into a worksheet. A chart sheet is a chart that is a sheet of its own.
There is a permission problem:
I got it from the comments here: http://www.php.net/manual/en/class.com.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With