PHPExcel:以字符串形式读取所有值(日期,时间,数字) [英] PHPExcel: Read all values (date, time, numbers) as strings
问题描述
我遇到日期和时间问题.我希望它们像在Excel工作簿中一样被阅读.
I am facing issues with dates and time. I want them to be read just like they appear in the excel workbook.
所以,我相信,如果我使用toArray()获取工作表的所有单元格,那么我应该做一些事情(某种格式转换),将所有单元格映射为字符串,日期,时间等.
So, I believe if I get all cells of the sheet using toArray(), then I should simply do something (some format conversion) that will map all cells as strings, dates, times etc.
OR可能有诸如load之类的功能,该功能可以将工作簿中的所有数据作为字符串加载,而无需进行任何格式化或其他复杂处理.
OR may be there is function like load, which load all data in the workbook as string without any formating or other complex stuff.
推荐答案
toArray()支持以下参数:
toArray() supports the following arguments:
/**
* @param mixed $nullValue Value returned in the array entry if a cell doesn't
* exist
* @param boolean $calculateFormulas Should formulas be calculated?
* @param boolean $formatData Should formatting be applied to cell values?
* @param boolean $returnCellRef False - Return a simple array of rows and
* columns indexed by number counting from zero
* True - Return rows and columns indexed by their
* actual row and column IDs
*/
如此
toArray(NULL,TRUE,TRUE);
将完全返回工作表中所有单元格的值(计算和格式化),使其与Excel本身中的显示完全相同.
will return all the cell values in the worksheet (calculated and formatted) exactly as they appear in Excel itself.
因此日期将返回为(例如)2011年12月21日07:30,而不是47239.318(取决于单元格的格式掩码).其他数字单元格可能会返回21,357.00(取决于该单元格的格式掩码),因此它是一把两刃剑.
So dates will be returned as (for example) 21-Dec-2011 07:30 rather than 47239.318 (depending on the format mask for the cell). Other numeric cells could be returned as 21,357.00 (depending on the format masking for that cell) so it is a two-edged sword.
这篇关于PHPExcel:以字符串形式读取所有值(日期,时间,数字)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!