fpspreadsheet: Fix violated file formation limitations when reading some xls files (http://www.lazarusforum.de/viewtopic.php?f=18&t=10824&start=15)
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5987 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
0b17d047d6
commit
05bdb8bb88
@ -1313,24 +1313,12 @@ procedure TsSpreadBIFF2Writer.PopulatePalette(AWorkbook: TsWorkbook);
|
||||
begin
|
||||
FPalette.Clear;
|
||||
FPalette.AddBuiltinColors(false);
|
||||
// The next instruction creates an error log entry if the workbook contains
|
||||
// more colors than the default 8. This is because BIFF2 can only have a
|
||||
// palette with 8 colors.
|
||||
{ The next instruction creates an error log entry in CheckLimitations
|
||||
if the workbook contains more colors than the default 8.
|
||||
This is because BIFF2 can only have a palette with 8 colors. }
|
||||
FPalette.CollectFromWorkbook(AWorkbook);
|
||||
end;
|
||||
|
||||
(*
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Builds up the list of number formats to be written to the biff2 file.
|
||||
Unlike biff5+ no formats are added here because biff2 supports only 21
|
||||
standard formats; these formats have been added by AddBuiltInFormats.
|
||||
Nothing to do here.
|
||||
-------------------------------------------------------------------------------}
|
||||
procedure TsSpreadBIFF2Writer.ListAllNumFormats;
|
||||
begin
|
||||
// Nothing to do here.
|
||||
end;
|
||||
*)
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
Attaches cell formatting data for the given cell to the current record.
|
||||
Is called from all writing methods of cell contents and rows
|
||||
|
@ -1242,12 +1242,15 @@ begin
|
||||
FPalette.Clear;
|
||||
FPalette.AddBuiltinColors(true);
|
||||
FPalette.CollectFromWorkbook(AWorkbook);
|
||||
// Fill up Excel colors of the standard palette to avoid empty color
|
||||
// place holders in Excel's colordialog.
|
||||
for i := 16 to High(PALETTE_BIFF5) do
|
||||
|
||||
{ Fill up Excel colors of the standard palette to avoid empty color
|
||||
place holders in Excel's colordialog. }
|
||||
i := 16;
|
||||
while (i <= High(PALETTE_BIFF5)) and (FPalette.Count < 64) do begin
|
||||
FPalette.AddColor(PALETTE_BIFF5[i]);
|
||||
// The BIFF5 palette contains duplicate colors -> don't use AddUniqueColor
|
||||
// FPalette.AddUniqueColor(PALETTE_BIFF5[i]);
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
@ -2238,12 +2238,15 @@ begin
|
||||
FPalette.Clear;
|
||||
FPalette.AddBuiltinColors(true);
|
||||
FPalette.CollectFromWorkbook(AWorkbook);
|
||||
// Fill up Excel colors of the standard palette to avoid empty color
|
||||
// place holders in Excel's colordialog.
|
||||
for i := 16 to High(PALETTE_BIFF8) do
|
||||
|
||||
{ Fill up Excel colors of the standard palette to avoid empty color
|
||||
place holders in Excel's colordialog. }
|
||||
i := 16;
|
||||
while (i <= High(PALETTE_BIFF8)) and (FPalette.Count < 64) do begin
|
||||
FPalette.AddColor(PALETTE_BIFF8[i]);
|
||||
// The BIFF8 palette contains duplicate colors -> don't use AddUniqueColor
|
||||
// FPalette.AddUniqueColor(PALETTE_BIFF8[i]);
|
||||
inc(i);
|
||||
end;
|
||||
end;
|
||||
|
||||
{@@ ----------------------------------------------------------------------------
|
||||
|
@ -1446,6 +1446,7 @@ begin
|
||||
{ Read column start and end index of column range }
|
||||
c1 := WordLEToN(AStream.ReadWord);
|
||||
c2 := WordLEToN(AStream.ReadWord);
|
||||
if c2 = 256 then dec(c2); // If columns are used Excel writes last index 256 - but it should be 255 ?!
|
||||
|
||||
{ Read col width in 1/256 of the width of "0" character }
|
||||
w := WordLEToN(AStream.ReadWord);
|
||||
|
Loading…
Reference in New Issue
Block a user