From 963fa9bc2f50c2a970e968fd431a0fc9c85ee0de Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Wed, 19 Oct 2022 20:40:44 +0000 Subject: [PATCH] fpspreadsheet: Adapt virtual mode writer to ods writer after r8574. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8575 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpspreadsheet/source/common/xlscommon.pas | 9 ++++----- components/fpspreadsheet/source/common/xlsxml.pas | 8 +++----- components/fpspreadsheet/source/common/xlsxooxml.pas | 4 ++-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/fpspreadsheet/source/common/xlscommon.pas b/components/fpspreadsheet/source/common/xlscommon.pas index 21ab933af..c540dd910 100644 --- a/components/fpspreadsheet/source/common/xlscommon.pas +++ b/components/fpspreadsheet/source/common/xlscommon.pas @@ -5814,14 +5814,13 @@ begin for c := 0 to LongInt(sheet.VirtualColCount) - 1 do begin lCell.Row := r; // to silence a compiler hint... - InitCell(lCell); + InitCell(ASheet, r, c, lCell); lCell.Worksheet := ASheet; value := varNull; styleCell := nil; sheet.OnWriteCellData(sheet, r, c, value, styleCell); - if styleCell <> nil then lCell := styleCell^; - lCell.Row := r; - lCell.Col := c; + if styleCell <> nil then + lCell.FormatIndex := styleCell^.FormatIndex; if VarIsNull(value) then begin // ignore empty cells that don't have a format if styleCell <> nil then @@ -5837,7 +5836,7 @@ begin if VarType(value) = varDate then begin lCell.ContentType := cctDateTime; - lCell.DateTimeValue := StrToDateTime(VarToStr(value), Workbook.FormatSettings); + lCell.DateTimeValue := VarToDateTime(value); end else if VarIsStr(value) then begin diff --git a/components/fpspreadsheet/source/common/xlsxml.pas b/components/fpspreadsheet/source/common/xlsxml.pas index 35fffc296..880b49e20 100644 --- a/components/fpspreadsheet/source/common/xlsxml.pas +++ b/components/fpspreadsheet/source/common/xlsxml.pas @@ -2419,14 +2419,12 @@ begin begin if (boVirtualMode in FWorkbook.Options) then begin lCell.Row := ARow; // to silence a compiler hint - InitCell(lCell); + InitCell(AWorksheet, ARow, c, lCell); value := varNull; styleCell := nil; sheet.OnWriteCellData(sheet, ARow, c, value, styleCell); if styleCell <> nil then - lCell := styleCell^; - lCell.Row := ARow; - lCell.Col := c; + lCell.FormatIndex := styleCell^.FormatIndex; if VarIsNull(value) then begin if styleCell <> nil then @@ -2442,7 +2440,7 @@ begin if VarType(value) = varDate then begin lCell.ContentType := cctDateTime; - lCell.DateTimeValue := StrToDateTime(VarToStr(value), Workbook.FormatSettings); // was: StrToDate + lCell.DateTimeValue := VarToDateTime(value); end else if VarIsStr(value) then begin diff --git a/components/fpspreadsheet/source/common/xlsxooxml.pas b/components/fpspreadsheet/source/common/xlsxooxml.pas index 43f4736c1..82ca6a833 100644 --- a/components/fpspreadsheet/source/common/xlsxooxml.pas +++ b/components/fpspreadsheet/source/common/xlsxooxml.pas @@ -5719,7 +5719,7 @@ begin styleCell := nil; sheet.OnWriteCellData(sheet, r, c, value, styleCell); if styleCell <> nil then - lCell := styleCell^; + lCell.FormatIndex := styleCell^.FormatIndex; lCell.Row := r; lCell.Col := c; if VarIsNull(value) then @@ -5737,7 +5737,7 @@ begin if VarType(value) = varDate then begin lCell.ContentType := cctDateTime; - lCell.DateTimeValue := StrToDateTime(VarToStr(value), Workbook.FormatSettings); // was: StrToDate + lCell.DateTimeValue := VarToDateTime(value); end else if VarIsStr(value) then begin