- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
美好的一天。我使用 PhpSpreadsheet 的库来导入 xlsx。
在 xlsx 的 I 列中,我有这个值 20/10/1970 00:00:00
显示为 1970-10-20 00:00:00
但是当我导入它时:
$dataArray = $spreadsheet->getActiveSheet()
->rangeToArray(
'A2:AO3', // The worksheet range that we want to retrieve
NULL, // Value that should be returned for empty cells
NULL, // Should formulas be calculated (the equivalent of getCalculatedValue() for each cell)
TRUE, // Should values be formatted (the equivalent of getFormattedValue() for each cell)
TRUE // Should the array be indexed by cell row and cell column
);
我收到奇怪的 ["I"] => float(25861)
请帮助我获取此字段中的 Carbon 数据。
如果我尝试像时间戳一样转换此 float ,我会收到 01/01/1970
而不是 10/20/1970
我收到的其他日期如 ["J"] => float(43195.4092014)
最佳答案
Excel 中的日期与其他软件/编程语言中的日期不同。
Excel 从 1900-01-01 开始计数,与 UNIX 从 1970-01-01 开始计数不同。
返回的数字是从 1900-01-01 开始的天数的浮点值, float 的小数部分是一天中的时间。
例如 25861.5
是 1970-10-20 12:00(“Y-m-d h.i”)。
要转换为 UNIX,您应该使用返回值 - 25569(Excel 中的 1970-01-01)并乘以 86400(以秒为单位的一天)。
在 Excel 中,如果将 25861 和 25569 格式化为日期:
你得到的另一个 float 43195.4092013889
echo date("Y-m-d h:i", (43195.4092013889-25569)*86400); //2018-04-05 11:49 (mind the timezones)
关于PhpSpreadsheet 格式化从 XLSX 导入的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50366682/
好吧,除了对我来说很神秘的 API 文档外,我没有找到图表的任何文档,所以如果任何 PHP 电子表格看到这个,请考虑记录这个类。我的问题是如何绘制饼图并将其实现到excel表中,直接查看或将其保存到文
我想使用 phpspreadsheet 在 excel 中设置页面设置。我发现使用来自 here 的 phpexcel 来做到这一点.我不知道在 PHPExcel_Worksheet_PageSe
我已经使用 Composer 安装了 phpoffice/phpspreadsheet。它安装在基本的“供应商”目录中。但是,我需要使用它的地方是在子域目录中。 我手动将其移至不同的“供应商”目录。
使用phpSpredSheet开始使用PHP。测试基本代码会返回错误FATAL ERROR:UNAUCAT ERROR:CLASS“PhpOffice\PhpSpreadSheet\SpreadShe
我正在使用 PHP 库 PhpSpreadsheet并希望使用循环遍历单元格和行来使用 MySQL 表中的数据填充电子表格 (xlsx),类似于此: .------------------------
我需要检查当前是否使用 PHPSpreadsheet 打开了 excel 文件。 我想到了一个解决方案,处理这条线 $writer->save(file_name)进入 if else条件,但仍然无法
我正在尝试使用 PHPSpreadsheet 格式化时间单元格,但在查看公式栏时它似乎也包括日期。从字符串、日期时间对象或 unix 时间戳转换时,似乎也存在一些不一致。 getActiveSheet
我的 phpSpreadSheet 文件有问题。 Link to PhpSpreadSheet Documentation 我制作了工作簿并添加了一堆带有名称的工作表。当我记录工作表的数量及其名称时,
我正在使用 PHPSpreadsheet 来处理一些任务。 我想要做的是获取字段的填充颜色。 load("missingean.xlsx"); $allMissing = $spreadsheet->
我是一个长期的读者,但对提问还是陌生的。如果我以某种方式问错了,请纠正我。 简介 我们正在将我们的服务器从 PHP 5.4 升级到 PHP 7.2,与新版本的 PHP 不完全兼容的库之一是 PHPEx
我有一个包含 3070 个值的多维数组 $tbl= array( array( "KDNR" => 1, "GESCHL" => "test", "TITEL" => "t
我想用 PHPSpreadsheet 计算两个日期时间之间的差异(以小时为单位)。 Excel 是这样做的: A1 和 A2 单元格格式为: 这是网络上的结果: 当我通过 PHPSpreadsheet
我在我的 php 代码中创建了一个带有一个选项卡的 excel 文件并为其命名。 我使用的代码是这样的: // CREATE PHPSPREADSHEET OBJECT require "../ven
使用 PhpSpreadsheet,我想为 Excel 单元格设置白色背景。 $cells = 'A1'; $spreadsheet ->getActiveSheet() ->getS
我需要生成一个excel文件(xls)并在生成后触发下载。 我在 documentation 中找到了这个例子. getActiveSheet(); $sheet->setCellValue('A1'
我已经生成了 xmlx 文件,我可以保存它并通过以下方式提供给用户: $writer->save('hello world.xlsx'); header('Location: hello world.
我有以下单元格数据: bla bla bla abcd efgh ijkl 注意,abcd 是粗体,efgh 是斜体,ijkl 同时是粗体和斜体。 我想读取整个单元格的数据,并将其保存在数据库中,这样
我有以下单元格数据: bla bla bla abcd efgh ijkl 注意,abcd 是粗体,efgh 是斜体,ijkl 同时是粗体和斜体。 我想读取整个单元格的数据,并将其保存在数据库中,这样
如何使用 PHPSpreadsheet\Reader\Xlsx::load() 方法找出已加载的行数? 我也找不到在电子表格或工作表类中获取行数的方法(或属性)。 顺便说一句,我正在使用以下代码: $
我一直在尝试设置特定列或整个电子表格的默认格式。我正在使用 PhpOffice\PhpSpreadsheet 包来创建 Excel 电子表格。有没有办法一次设置整张或整列的格式? 以下是我如何使用该库
我是一名优秀的程序员,十分优秀!