Tag: phpexcel

如何在PHPExcel的单元格中设置文本方向?

我必须在内联的RTL和LTR语言组合的单元格中编写文本,而先前的语言是RTL语言。 所以我需要将PHPExcel生成的xls文件中的文本默认为RTL。 我能做什么?

引用mysqli_connect.php中断PHPExcel Downloader

我是一个新的开发人员,最近完成了为我的公司编写一个简单的PHP MySQL数据库pipe理系统。 现在我已经完成了它的工作 ,我想要保证它的安全,实现我可以在网上find的所有安全最佳实践(例如:正则expression式,在web目录之外有mysqli_connect.php,在脚本内部有连接string等等)在我上网之前。 我已经编辑了这些代码之外的一些个人信息,并将其replace为它的工作内容,但括号内。 如果可能的话,我不想把它留在网上。 通常情况下,我只能参照mysqli_connect.php来处理数据库,如下所示: require_once ('..\mysqli_connect.php'); 我的DBMS的一个function是“下载到excel”button。 它完美的工作, 但只有当我有直接连接的文件内的连接。 如果我尝试像上面的示例中那样编写连接,Excel文件将显示以下错误消息: Excel cannot open the file 'xyz.xlsx' because the file format or extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file. 当我直接在ExcelDownload.php中写入连接时,Excel文件正确下载。 连接string如下所示: $dbc = @mysqli_connect( '[myhost]', '[myusername]', '[mypassword]', […]

用PHPExcel写入Excel文件

那么,我想用一个PHP脚本来写一个Excel文件。 实际上,当用户提交表单时,我们会得到邮件和当前date,以便将其放入Excel中。 邮件必须在一列,date也一样。 所以这是我的forms(一个经典forms): <form action="mail.php" method="POST"> <label for="name">Nom*<br /> <input id="name" type="text" name="Nom" /> </label><br /><br /> <label for="mail">Mail*<br /> <input id="mail" type="email" name="Email" /> </label><br /><br /> <label for="tel">Téléphone*<br /> <input id="tel" type="text" name="Téléphone" /> </label><br /><br /> <label for="comment">Commentaire*<br /> <textarea id="comment" type="text" name="Commentaires"> </textarea> </label><br /><br /> <input type="submit" value="Envoyer" /> […]

用phpexcel从其他表中读取公式

试图维护一些旧的灰尘代码,我在一个导入symfony命令中面临phpexcel的问题。 看起来,库不能正确地计算出与活动工作表相同文档的另一页链接的公式。 我得到的错误是: [PHPExcel_Calculation_Exception] Price Template Map!B2 -> Invalid cell coordinate A 我的代码是: try { $inputFileType = \PHPExcel_IOFactory::identify($filePath); $objReader = \PHPExcel_IOFactory::createReader($inputFileType); $objReader->setLoadSheetsOnly(array($this->getListName(), 'Template Info')); $objReader->setIncludeCharts(true); $objPHPExcel = $objReader->load($filePath); } catch (\Exception $e) { throw new \Exception("Invalid file"); } $sheet = $objPHPExcel->getActiveSheet(); $highestRow = $sheet->getHighestRow(); $highestColumn = $sheet->getHighestColumn(); $fieldsNumber = array(); $filterData = array(); $templateIdList = […]

PHPExcel值在合并行上删除

在我的应用程序中,我有一个包含产品的json文件。 在一个循环中,我遍历每个项目并将它们放入单元格中。 $this->row = 4; foreach ($this->json['products'] as $product) { $this->template->getActiveSheet()->setCellValueByColumnAndRow(6, $this->row, $product); $this->row++; } 之后,我正在设置excel文件的样式 $this->template->getActiveSheet()->mergeCells('J6:K6'); 基本上将J行和K行相互合并,但是由于这个原因, K的值被删除。 如何在合并不可访问的行后将K的值dynamic设置为下一行值?

未find类“CI_Excel”

当我加载Excel的库时,我得到了这个错误。 我遵循这个教程中的一切,仍然有一些错误 我使用codeigniter框架。 在线196上的/var/www/html/warehouse/system/core/Common.php中找不到“CI_Excel”类 这是我的控制器 class Dashboard extends CI_Controller { public function __construct(){ parent::__construct(); $this->load->library('excel'); $this->load->model('dashboard_model'); } public function download(){ $this->excel->setActiveSheetIndex(0); $this->excel->getActiveSheet()->setTitle('Warehouse List'); //$this->load->database(); $results = $this->dashboard_model->get_all(); $this->excel->getActiveSheet()->fromArray($results); $filename='Warehouse List.xls'; header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="'.$filename.'"'); header('Cache-Control: max-age=0'); $objWriter = PHPExcel_IOFactory::createWriter($this->excel, 'Excel5'); $objWriter->save('php://output'); } } 这是我的图书馆的Excel类 <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); require_once APPPATH."/third_party/Classes/PHPExcel.php"; class […]

PHPExcel用公式有条件地格式化一个范围

我有以下代码: $vOffset = 2; $offset = 6; $formatRows = 100; $formatColumns = 100; //set conditional formatting in place for($row=$vOffset;$i<$formatRows;$row++){ for($col=$offset+1;$col<$formatColumns;$col+3){ //prepare conditional styles //if verbal is bigger $conditionalStyle_RED = new PHPExcel\Style_Conditional(); $conditionalStyle_RED->setConditionType(PHPExcel\Style_Conditional::CONDITION_CELLIS); $conditionalStyle_RED->addCondition( "=" . $this->coordinates($col, $row) . " > " . $this->coordinates($col+1,$row) ); $conditionalStyle_RED->getStyle()->getFont()->getColor()->setARGB(PHPExcel\Style_Color::COLOR_RED); array_push($conditionalStyles, $conditionalStyle_RED); $this->getActiveSheet() ->getStyle($this->coordinates($col, $row) . ':' . $this->coordinates($col+1, $row)) […]

维护图表phpexcel

我正在使用phpexcel 1.8来编辑xls。 特别是,原始文件有3张 首先用图表和值 第二个与图像 第三个有一些价值 这是代码 $excel2 = PHPExcel_IOFactory::createReader('Excel2007'); $excel2 = $excel2->load('test.xlsx'); // Empty Sheet $excel2->setActiveSheetIndex(0); $excel2->getActiveSheet()->setCellValue('A5', '999')->setCellValue('D7', '5'); $excel2->setActiveSheetIndex(2); $excel2->getActiveSheet()->setCellValue('A7', '111'); $objWriter = PHPExcel_IOFactory::createWriter($excel2, 'Excel2007'); $objWriter->save('Nimit New.xlsx'); 生成的文件在第二张纸上有图像,但在第一张纸上没有图像。 是否有可能保持图(更新值)? 谢谢

如何使用PhpExcel生成date格式?

$date='30-09-11' $objPHPExcel->getActiveSheet() ->setCellValue(toAlphaNumber($tmpCOunt + 9) . $rowNbmr, $date) ->getStyle(toAlphaNumber($tmpCOunt + 9) . $rowNbmr )->applyFromArray( array( 'font' => array('color' => array('rgb' => '000000')) )) ->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_XLSX14 ) ; 在Excel中,单元格显示它是一个“date”,但在select单元格并按任意键之前,我无法操作它,然后自动将它alignment到右侧,我就能够操作为date。

PHPEXCEL:如何从excel文件读取每一行并插入数据库

我想上传一个excel文件,逐行读取并将数据插入到数据库中。 我怎么可以这样做? 这是我迄今为止所尝试的: for ($row = 1; $row <= $highestRow; $row++) { // Read a row of data into an array $rowData = $sheet->rangeToArray('A' . $row . ':' . $highestColumn . $row, NULL, TRUE, FALSE); // This line works as $sheet->rangeToArray('A1:E1') that is selecting all the cells in that row from cell A to highest […]