doushuo1080 2013-04-11 04:38
浏览 3327

我可以使用application / vnd.openxmlformats-officedocument.spreadsheetml.sheet打开xlsx文件吗?

I want to open a xlsx file with PHP using application/vnd.openxmlformats- officedocument.spreadsheetml.sheet because COM does not work on the server.
Does someone know how to do this?

The commented section is the one I want to replace. I am doing this to force excel to calculate the values in the formulas because phpexcel is not getting the correct values.

If there a way to configure the COM to run in the server please let me know.

This is my code:

$inputFileName = 'FORMATO PEDIDO.xlsx';
                        $inputFileType = PHPExcel_IOFactory::identify($inputFileName);

                        $objPHPexcel = PHPExcel_IOFactory::load($inputFileName);
                        $objWorksheet = $objPHPexcel->setActiveSheetIndex(0);
                        $objWorksheet = $objPHPexcel->getActiveSheet(); 

                        $claves = $_POST['claves'];
                        $checked = $_POST['productos'];
                        $cantidades = $_POST['pallet'];
                        $id_sucursal_seleccionada = $_POST['recibe_sucursal'];
                        $sql_query = mysql_query("SELECT * FROM sucursal WHERE Id_Sucursal = '$id_sucursal_seleccionada'");
                        $sql_array = mysql_fetch_array($sql_query);
                        $nombre_sucursal = $sql_array['Nombre'];
                        $i=0;
                        $j=22;
                        foreach($claves as $clave_producto)
                        {
                            if($checked[$i])
                            {
                                $cantidad = $cantidades[$i];
                                $objWorksheet->getCell('B'.$j)->setValue($clave_producto); 
                                $objWorksheet->getCell('F'.$j)->setValue($cantidad);
                                $j++;
                            }
                            $i++;
                        }
                        $objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel,$inputFileType); 
                        $objWriter->setPreCalculateFormulas(false);
                        $objWriter->save($inputFileName); 

                        $workbook = "C:/Documents and Settings/sosam1/My Documents/Dropbox/htdocs/Merdiz/inventarios/FORMATO PEDIDO.xlsx";
                        $ex = new COM("Excel.application") or Die ("Did not connect");
                        $wkb = $ex->application->Workbooks->Open($workbook) or Die ("Did not open");
                        $ex->Application->ActiveWorkbook->Save();
                        $ex->application->ActiveWorkbook->Close("False");    

                        $objPHPexcel = PHPExcel_IOFactory::load($inputFileName);
                        $objWorksheet = $objPHPexcel->setActiveSheetIndex(0);
                        $objWorksheet = $objPHPexcel->getActiveSheet();
  • 写回答

2条回答 默认 最新

  • dongliang1893 2013-04-11 04:43
    关注

    Have you tried the code from- http://phpexcel.codeplex.com/

    评论

报告相同问题?

悬赏问题

  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)