[英]Copy the cell format from .xlsx file using Spreadsheett::ParseXLSX to write another cell using EXCEL:WRITER::XLSX?
[英]How to copy the format of the .xlsx cell using "Excel::Writer::XLSX" reader to the copied cell using "Spreadsheet::WriteExcel" writer?
我是 Perl 的新手,如果它是非常基本的,請耐心等待。 下面的代碼可以很好地將 excel 值復制到另一個值。 我在復制格式時遇到問題。 我需要從讀取文件中復制格式值,然后將其分配給寫入單元格-self 是需要更改的變量。
代碼:-
#!/home/utils/perl-5.24/5.24.2-058/bin/perl -w
use warnings;
use Spreadsheet::XLSX;
use Excel::Writer::XLSX;
#reading the sheet using below perl parser
my $excel = Spreadsheet::XLSX -> new ('abcd.xlsx');
#writing the sheet using below parser
my $excel_2 = Excel::Writer::XLSX -> new ('abcd_N.xlsx');
my $format = $excel_2->add_format();
#loop to read the hseet and write
foreach my $sheet (@{$excel -> {Worksheet}})
{
printf("Sheet: %s\n", $sheet->{Name});
my $sheet_write = $excel_2->add_worksheet($sheet->{Name});
$sheet -> {MaxRow} ||= $sheet -> {MinRow};
foreach my $row ($sheet -> {MinRow} .. $sheet -> {MaxRow})
{
$sheet -> {MaxCol} ||= $sheet -> {MinCol};
foreach my $col ($sheet -> {MinCol} .. $sheet -> {MaxCol})
{
my $cell = $sheet -> {Cells} [$row] [$col];
if ($cell)
{
printf("( %s , %s ) => %s\n", $row, $col, $cell -> {Val});
$sheet_write->write($row, $col,$cell -> {Val},$self);
}
}
}
}
我不記得電子表格:: XLSX 具有復制單元格格式的“能力”。 這是一個非常基本的 cpan 包,用於獲取單元格內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.