diff --git a/components/fpspreadsheet/examples/excel8demo/excel8write.lpr b/components/fpspreadsheet/examples/excel8demo/excel8write.lpr
index 187f2dc3c..33fd381cd 100644
--- a/components/fpspreadsheet/examples/excel8demo/excel8write.lpr
+++ b/components/fpspreadsheet/examples/excel8demo/excel8write.lpr
@@ -40,6 +40,7 @@ begin
MyWorkbook.UsePalette(@PALETTE_BIFF8, Length(PALETTE_BIFF8));
MyWorksheet := MyWorkbook.AddWorksheet(Str_Worksheet1);
+ MyWorksheet.ShowGridLines := false;
// Write some cells
MyWorksheet.WriteNumber(0, 0, 1.0);// A1
diff --git a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
index 0d1d92593..f649425d6 100644
--- a/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
+++ b/components/fpspreadsheet/examples/fpsgrid/fpsgrid.lpi
@@ -127,11 +127,15 @@
+
-
-
+
+
+
+
+
@@ -148,11 +152,10 @@
-
-
-
+
+
@@ -314,9 +317,6 @@
-
-
-
@@ -372,123 +372,127 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
+
+
+
+
diff --git a/components/fpspreadsheet/examples/fpsgrid/mainform.pas b/components/fpspreadsheet/examples/fpsgrid/mainform.pas
index 032372d04..309cbb4db 100644
--- a/components/fpspreadsheet/examples/fpsgrid/mainform.pas
+++ b/components/fpspreadsheet/examples/fpsgrid/mainform.pas
@@ -138,6 +138,7 @@ begin
AFilename,
GetFileFormatName(sWorksheetGrid1.Workbook.FileFormat)
]);
+ CbDisplayGrid.Checked := sWorksheetGrid1.Worksheet.ShowGridLines;
// Create a tab in the pagecontrol for each worksheet contained in the workbook
// This would be easer with a TTabControl. This has display issues, though.
diff --git a/components/fpspreadsheet/fpspreadsheet.pas b/components/fpspreadsheet/fpspreadsheet.pas
index 9cc46fda1..d8b91ac7b 100755
--- a/components/fpspreadsheet/fpspreadsheet.pas
+++ b/components/fpspreadsheet/fpspreadsheet.pas
@@ -315,6 +315,9 @@ type
FCells: TAvlTree; // Items are TCell
FCurrentNode: TAVLTreeNode; // For GetFirstCell and GetNextCell
FRows, FCols: TIndexedAVLTree; // This lists contain only rows or cols with styles different from the standard
+ FShowGridLines: Boolean;
+ FShowHeaders: Boolean;
+ FSelected: Boolean;
procedure RemoveCallback(data, arg: pointer);
public
Name: string;
@@ -384,6 +387,10 @@ type
property Cols: TIndexedAVLTree read FCols;
property Rows: TIndexedAVLTree read FRows;
property Workbook: TsWorkbook read FWorkbook;
+ // These are properties to interface to fpspreadsheetgrid.
+ property ShowGridLines: Boolean read FShowGridLines write FShowGridLines;
+ property ShowHeaders: Boolean read FShowHeaders write FShowHeaders;
+ property Selected: Boolean read FSelected write FSelected;
end;
{ TsWorkbook }
diff --git a/components/fpspreadsheet/fpspreadsheetgrid.pas b/components/fpspreadsheet/fpspreadsheetgrid.pas
index 1fa2b850a..14a4ecdd7 100644
--- a/components/fpspreadsheet/fpspreadsheetgrid.pas
+++ b/components/fpspreadsheet/fpspreadsheetgrid.pas
@@ -813,6 +813,10 @@ begin
RowHeights[i] := DefaultRowHeight;
end;
end;
+ if FWorksheet.ShowGridLines then
+ Options := Options + [goHorzLine, goVertLine]
+ else
+ Options := Options - [goHorzLine, goVertLine];
end
else
for i:=0 to RowCount-1 do begin
diff --git a/components/fpspreadsheet/xlsbiff5.pas b/components/fpspreadsheet/xlsbiff5.pas
index b35917ff5..50b5ea96d 100755
--- a/components/fpspreadsheet/xlsbiff5.pas
+++ b/components/fpspreadsheet/xlsbiff5.pas
@@ -126,7 +126,7 @@ type
const AFormula: TsRPNFormula; ACell: PCell); override;
procedure WriteStyle(AStream: TStream);
procedure WriteWindow1(AStream: TStream);
- procedure WriteWindow2(AStream: TStream; ASheetSelected: Boolean);
+ procedure WriteWindow2(AStream: TStream; ASheet: TsWorksheet);
procedure WriteXF(AStream: TStream; AFontIndex: Word;
AFormatIndex: Word; AXF_TYPE_PROT, ATextRotation: Byte; ABorders: TsCellBorders;
const ABorderStyles: TsCellBorderStyles; AHorAlignment: TsHorAlignment = haDefault;
@@ -230,8 +230,6 @@ const
INT_EXCEL_ID_ROWINFO = $0208;
INT_EXCEL_ID_STYLE = $0293;
INT_EXCEL_ID_WINDOW1 = $003D;
- INT_EXCEL_ID_WINDOW2 = $023E;
- INT_EXCEL_ID_XF = $00E0;
INT_EXCEL_ID_RSTRING = $00D6;
INT_EXCEL_ID_RK = $027E;
INT_EXCEL_ID_MULRK = $00BD;
@@ -291,19 +289,6 @@ const
MASK_WINDOW1_OPTION_VERT_SCROLL_VISIBLE = $0010;
MASK_WINDOW1_OPTION_WORKSHEET_TAB_VISIBLE = $0020;
- { WINDOW2 record constants }
- MASK_WINDOW2_OPTION_SHOW_FORMULAS = $0001;
- MASK_WINDOW2_OPTION_SHOW_GRID_LINES = $0002;
- MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS = $0004;
- MASK_WINDOW2_OPTION_PANES_ARE_FROZEN = $0008;
- MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES = $0010;
- MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR = $0020;
- MASK_WINDOW2_OPTION_COLUMNS_RIGHT_TO_LEFT = $0040;
- MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS = $0080;
- MASK_WINDOW2_OPTION_REMOVE_SPLITS_ON_UNFREEZE = $0100;
- MASK_WINDOW2_OPTION_SHEET_SELECTED = $0200;
- MASK_WINDOW2_OPTION_SHEET_ACTIVE = $0400;
-
{ XF substructures }
{ XF substructures --- see xlscommon! }
@@ -426,7 +411,7 @@ begin
WriteIndex(AStream);
WriteColInfos(AStream, sheet);
WriteDimensions(AStream, sheet);
- WriteWindow2(AStream, True);
+ WriteWindow2(AStream, sheet);
WriteCellsToStream(AStream, sheet.Cells);
WriteEOF(AStream);
end;
@@ -1017,7 +1002,7 @@ end;
*
*******************************************************************}
procedure TsSpreadBIFF5Writer.WriteWindow2(AStream: TStream;
- ASheetSelected: Boolean);
+ ASheet: TsWorksheet);
var
Options: Word;
begin
@@ -1026,14 +1011,18 @@ begin
AStream.WriteWord(WordToLE(10));
{ Options flags }
- Options := MASK_WINDOW2_OPTION_SHOW_GRID_LINES or
- MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS or
- MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES or
- MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR or
- MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS or
- MASK_WINDOW2_OPTION_SHEET_ACTIVE;
+ Options :=
+ MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES or
+ MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR or
+ MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS or
+ MASK_WINDOW2_OPTION_SHEET_ACTIVE;
- if ASheetSelected then Options := Options or MASK_WINDOW2_OPTION_SHEET_SELECTED;
+ if ASheet.ShowGridLines then
+ Options := Options or MASK_WINDOW2_OPTION_SHOW_GRID_LINES;
+ if ASheet.ShowHeaders then
+ Options := Options or MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS;
+ if ASheet.Selected then
+ Options := Options or MASK_WINDOW2_OPTION_SHEET_SELECTED;
AStream.WriteWord(WordToLE(Options));
@@ -1352,6 +1341,7 @@ begin
INT_EXCEL_ID_COLINFO: ReadColInfo(AStream);
INT_EXCEL_ID_ROWINFO: ReadRowInfo(AStream);
INT_EXCEL_ID_FORMULA: ReadFormulaExcel(AStream);
+ INT_EXCEL_ID_WINDOW2: ReadWindow2(AStream);
INT_EXCEL_ID_BOF: ;
INT_EXCEL_ID_EOF: SectionEOF := True;
// Show unsupported record types to console.
diff --git a/components/fpspreadsheet/xlsbiff8.pas b/components/fpspreadsheet/xlsbiff8.pas
index 2ce2b978a..bdb69b389 100755
--- a/components/fpspreadsheet/xlsbiff8.pas
+++ b/components/fpspreadsheet/xlsbiff8.pas
@@ -127,7 +127,7 @@ type
const AFormula: TsRPNFormula; ACell: PCell); override;
procedure WriteStyle(AStream: TStream);
procedure WriteWindow1(AStream: TStream);
- procedure WriteWindow2(AStream: TStream; ASheetSelected: Boolean);
+ procedure WriteWindow2(AStream: TStream; ASheet: TsWorksheet);
procedure WriteXF(AStream: TStream; AFontIndex: Word;
AFormatIndex: Word; AXF_TYPE_PROT, ATextRotation: Byte; ABorders: TsCellBorders;
const ABorderStyles: TsCellBorderStyles; AHorAlignment: TsHorAlignment = haDefault;
@@ -270,19 +270,6 @@ const
MASK_WINDOW1_OPTION_VERT_SCROLL_VISIBLE = $0010;
MASK_WINDOW1_OPTION_WORKSHEET_TAB_VISIBLE = $0020;
- { WINDOW2 record constants }
- MASK_WINDOW2_OPTION_SHOW_FORMULAS = $0001;
- MASK_WINDOW2_OPTION_SHOW_GRID_LINES = $0002;
- MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS = $0004;
- MASK_WINDOW2_OPTION_PANES_ARE_FROZEN = $0008;
- MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES = $0010;
- MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR = $0020;
- MASK_WINDOW2_OPTION_COLUMNS_RIGHT_TO_LEFT = $0040;
- MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS = $0080;
- MASK_WINDOW2_OPTION_REMOVE_SPLITS_ON_UNFREEZE = $0100;
- MASK_WINDOW2_OPTION_SHEET_SELECTED = $0200;
- MASK_WINDOW2_OPTION_SHEET_ACTIVE = $0400;
-
{ XF substructures }
{ XF_ROTATION }
@@ -514,7 +501,7 @@ begin
WriteIndex(AStream);
WriteColInfos(AStream, sheet);
WriteDimensions(AStream, sheet);
- WriteWindow2(AStream, True);
+ WriteWindow2(AStream, sheet);
WriteCellsToStream(AStream, sheet.Cells);
WriteEOF(AStream);
end;
@@ -1185,7 +1172,7 @@ end;
*
*******************************************************************}
procedure TsSpreadBIFF8Writer.WriteWindow2(AStream: TStream;
- ASheetSelected: Boolean);
+ ASheet: TsWorksheet);
var
Options: Word;
begin
@@ -1194,14 +1181,18 @@ begin
AStream.WriteWord(WordToLE(18));
{ Options flags }
- Options := MASK_WINDOW2_OPTION_SHOW_GRID_LINES or
- MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS or
- MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES or
- MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR or
- MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS or
- MASK_WINDOW2_OPTION_SHEET_ACTIVE;
+ Options :=
+ MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES or
+ MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR or
+ MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS or
+ MASK_WINDOW2_OPTION_SHEET_ACTIVE;
- if ASheetSelected then Options := Options or MASK_WINDOW2_OPTION_SHEET_SELECTED;
+ if ASheet.ShowGridLines then
+ Options := Options or MASK_WINDOW2_OPTION_SHOW_GRID_LINES;
+ if ASheet.ShowHeaders then
+ Options := Options or MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS;
+ if ASheet.Selected then
+ Options := Options or MASK_WINDOW2_OPTION_SHEET_SELECTED;
AStream.WriteWord(WordToLE(Options));
@@ -1601,6 +1592,7 @@ begin
INT_EXCEL_ID_LABELSST:ReadLabelSST(AStream); //BIFF8 only
INT_EXCEL_ID_COLINFO: ReadColInfo(AStream);
INT_EXCEL_ID_ROWINFO: ReadRowInfo(AStream);
+ INT_EXCEL_ID_WINDOW2: ReadWindow2(AStream);
INT_EXCEL_ID_BOF: ;
INT_EXCEL_ID_EOF: SectionEOF := True;
else
diff --git a/components/fpspreadsheet/xlscommon.pas b/components/fpspreadsheet/xlscommon.pas
index 9ba18681a..22c387a0c 100644
--- a/components/fpspreadsheet/xlscommon.pas
+++ b/components/fpspreadsheet/xlscommon.pas
@@ -27,6 +27,7 @@ const
INT_EXCEL_ID_BLANK = $0201;
INT_EXCEL_ID_NUMBER = $0203;
INT_EXCEL_ID_LABEL = $0204;
+ INT_EXCEL_ID_WINDOW2 = $023E;
{ FONT record constants }
INT_FONT_WEIGHT_NORMAL = $0190;
@@ -225,7 +226,6 @@ const
FORMAT_PERCENT_0_DECIMALS = 9; //percent, 0 decimals
FORMAT_PERCENT_2_DECIMALS = 10; //percent, 2 decimals
FORMAT_EXP_2_DECIMALS = 11; //exponent, 2 decimals
- FORMAT_SCI_1_DECIMAL = 48; //scientific, 1 decimal
FORMAT_SHORT_DATE = 14; //short date
FORMAT_DATE_DM = 16; //date D-MMM
FORMAT_DATE_MY = 17; //date MMM-YYYY
@@ -235,8 +235,22 @@ const
FORMAT_LONG_TIME = 21; //long time H:MM:SS
FORMAT_SHORT_DATETIME = 22; //short date+time
FORMAT_TIME_MS = 45; //time MM:SS
- FORMAT_TIME_MSZ = 47; //time MM:SS.0
FORMAT_TIME_INTERVAL = 46; //time [hh]:mm:ss, hh can be >24
+ FORMAT_TIME_MSZ = 47; //time MM:SS.0
+ FORMAT_SCI_1_DECIMAL = 48; //scientific, 1 decimal
+
+ { WINDOW2 record constants - BIFF3-BIFF8}
+ MASK_WINDOW2_OPTION_SHOW_FORMULAS = $0001;
+ MASK_WINDOW2_OPTION_SHOW_GRID_LINES = $0002;
+ MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS = $0004;
+ MASK_WINDOW2_OPTION_PANES_ARE_FROZEN = $0008;
+ MASK_WINDOW2_OPTION_SHOW_ZERO_VALUES = $0010;
+ MASK_WINDOW2_OPTION_AUTO_GRIDLINE_COLOR = $0020;
+ MASK_WINDOW2_OPTION_COLUMNS_RIGHT_TO_LEFT = $0040;
+ MASK_WINDOW2_OPTION_SHOW_OUTLINE_SYMBOLS = $0080;
+ MASK_WINDOW2_OPTION_REMOVE_SPLITS_ON_UNFREEZE = $0100; //BIFF5-BIFF8
+ MASK_WINDOW2_OPTION_SHEET_SELECTED = $0200; //BIFF5-BIFF8
+ MASK_WINDOW2_OPTION_SHEET_ACTIVE = $0400; //BIFF5-BIFF8
{ XF substructures }
@@ -358,6 +372,8 @@ type
procedure ReadRowColXF(AStream: TStream; out ARow, ACol: Cardinal; out AXF: Word); virtual;
// Read row info
procedure ReadRowInfo(AStream: TStream); virtual;
+ // Read WINDOW2 record (gridlines, sheet headers)
+ procedure ReadWindow2(AStream: TStream); virtual;
public
constructor Create(AWorkbook: TsWorkbook); override;
destructor Destroy; override;
@@ -865,6 +881,22 @@ begin
end;
end;
+{ Reads the WINDOW2 record containing information like "show grid lines", or
+ "show sheet headers".
+ The record structure is different for BIFF5 and BIFF8, but we use here only
+ the common part.
+ BIFF2 is completely different and has to be overridden. }
+procedure TsSpreadBIFFReader.ReadWindow2(AStream: TStream);
+var
+ flags: Word;
+begin
+ flags := WordLEToN(AStream.ReadWord);
+ FWorksheet.ShowGridLines := (flags and MASK_WINDOW2_OPTION_SHOW_GRID_LINES <> 0);
+ FWorksheet.ShowHeaders := (flags and MASK_WINDOW2_OPTION_SHOW_SHEET_HEADERS <> 0);
+ FWorksheet.Selected := (flags and MASK_WINDOW2_OPTION_SHEET_SELECTED <> 0);
+end;
+
+
{ TsSpreadBIFFWriter }