简体   繁体   English

如何从 Perl 中的 XLSX 文件获取单元格格式?

[英]How to get cell formats from XLSX files in Perl?

I am able to find $cell->get_format() or $cell->format _hash in .xls files parser but not for xlsx format.我能够在 .xls 文件解析器中找到 $cell->get_format() 或 $cell->format _hash 但不适用于 xlsx 格式。 I am also open to use any XLSX parser for reading the spreadsheet.我也愿意使用任何 XLSX 解析器来阅读电子表格。 Basically I am copying one spreadsheet to another preserving the format.基本上我将一个电子表格复制到另一个保留格式。

I am new to the Perl, Please bear up with me if it's very basic.我是 Perl 的新手,如果它是非常基本的,请耐心等待。 The below code works fine copying in excel value to another.下面的代码可以很好地将 excel 值复制到另一个值。 I am having trouble copying the format.我在复制格式时遇到问题。 I need to copy the format value from the reading file and then assign it to writing cell- self is the variable need to change.我需要从读取文件中复制格式值,然后将其分配给写入单元格-self 是需要更改的变量。

The question I have asked Earlier How to copy the format of the .xlsx cell using "Excel::Writer::XLSX" reader to the copied cell using "Spreadsheet::WriteExcel" writer?我之前问过的问题如何使用“Excel::Writer::XLSX”阅读器将 .xlsx 单元格的格式复制到使用“Spreadsheet::WriteExcel”编写器的复制单元格? And I am open to any other XLSX parser in case this is not the right to copy the format of the cell.而且我对任何其他 XLSX 解析器持开放态度,以防这不是复制单元格格式的权利。

These modules cannot modify spreadsheets in place, so you need a reader and a writer.这些模块无法就地修改电子表格,因此您需要一个阅读器和一个编写器。 To read an XLSX file, use Spreadsheet::ParseXLSX which implements the same methods as Spreadsheet::ParseExcel but parses XLSX files, so its cells also have get_format which returns the properties listed here .要读取 XLSX 文件,请使用Spreadsheet::ParseXLSX ,它实现与Spreadsheet::ParseExcel相同的方法,但解析 XLSX 文件,因此其单元格也具有get_format ,它返回此处列出的属性。 To write a new spreadsheet use Excel::Writer::XLSX , which implements the same methods as Spreadsheet::WriteExcel but creates XLSX files.要编写新电子表格,请使用Excel::Writer::XLSX ,它实现与Spreadsheet::WriteExcel相同的方法,但会创建 XLSX 文件。 You would add formats to such a new sheet as described here .您可以将格式添加到此处所述的新工作表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM