-2

My requirement is to display charts present in MS Office excel 2007 in web page.

Can someone please help me getting it right by any language? PHP is my preference by i didn't get any help on google.

I have more than 1 chart in all sheets inside a single excel file.

PHPExcel and equivalent API's doesn't support chart import support, so only solution i see is to import excel sheets as image and display.

4

2 回答 2

2

Take a look at the 32chartreadwrite.php in PHPExcel's /Tests directory. This provides the basic code for reading an Excel 2007+ .xlsx file with its chart data.

$objReader = PHPExcel_IOFactory::createReader($fileType);
$objReader->setIncludeCharts(TRUE);
$objPHPExcel = $objReader->load($fileName);


PHPExcel_Settings::setChartRenderer(
    PHPExcel_Settings::CHART_RENDERER_JPGRAPH,
    dirname(__FILE__).'/../../libraries/Charts/jpgraph3.5.0b1/src'
);

$chart = $objPHPExcel->getSheetByName($sheetName)->getChartByName($chartName);
$chart->render();

While it doesn't support every feature (only a single Y-axis, for example) or every chart type (stock charts aren't supported by the renderer), it can work with a wide variety of chart types.

于 2012-07-10T20:47:50.763 回答
1

2 sec search on google for "php chart" gets me:

http://pchart.sourceforge.net/

A fully open source charting library...

Note that charting is not part of the excel per se. It is an object that is rendered by the charting library used by Excel. You still need to extrapolate the data from the excel spreadsheet and pass it on correctly to your charting engine...

于 2012-07-10T20:40:53.877 回答