开发者

Is it possible to create new worksheet and add data from file to it?

I have file what have two worksheets which I wish to use as templates.

In php I create new PHPExcel object and load data from first worksheet to it.

    $objReader = new PHPExcel_Reader_Excel5();
    $objReader->setLoadSheetsOnly('Page1');
    $objPHPExcel = $objReader->load('template.xls');

Then I need to create another worksheet in objPHPExcel and fill it with template from worksheet 'Page2' of file template.xls

But when I do like this:

    $objReader->setLoadSheetsOnly('Page2');
    $objWorksheet = $objPHPExcel->createSheet();
    $objWorksheet->setTitle('Sheet'.$sheetIndex);
    $objPHPExcel = $objRea开发者_运维技巧der->load($timesheetTemplatePath);

I get file with only last results.

How can I create worksheet and read data (with styles) from another file?


Try passing an index to createSheet method, in this case it would be 1:

$objWorksheet = $objPHPExcel->createSheet(1);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜