You've already forked lazarus-ccr
lazspreadsheet: Adds a cell debug info tool
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2604 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -45,7 +45,7 @@
|
||||
<UnitName Value="lazspreadsheet"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="../../components/fpspreadsheet/examples/lazspreadsheet/about.pas"/>
|
||||
<Filename Value="about.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="Form1"/>
|
||||
<HasResources Value="True"/>
|
||||
@ -53,7 +53,7 @@
|
||||
<UnitName Value="about"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="../../components/fpspreadsheet/examples/lazspreadsheet/mainform.pas"/>
|
||||
<Filename Value="mainform.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<ComponentName Value="lazfpsmainform"/>
|
||||
<HasResources Value="True"/>
|
||||
|
@ -3,41 +3,42 @@ object lazfpsmainform: Tlazfpsmainform
|
||||
Height = 401
|
||||
Top = 170
|
||||
Width = 700
|
||||
Caption = 'FPSpreadsheet Chart Example'
|
||||
Caption = 'LazSpreadsheet'
|
||||
ClientHeight = 401
|
||||
ClientWidth = 700
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '1.1'
|
||||
object pagesSheets: TPageControl
|
||||
Left = 0
|
||||
Height = 343
|
||||
Top = 58
|
||||
Height = 321
|
||||
Top = 80
|
||||
Width = 700
|
||||
Align = alClient
|
||||
TabOrder = 0
|
||||
end
|
||||
object Panel1: TPanel
|
||||
Left = 0
|
||||
Height = 58
|
||||
Height = 80
|
||||
Top = 0
|
||||
Width = 700
|
||||
Align = alTop
|
||||
ClientHeight = 58
|
||||
ClientHeight = 80
|
||||
ClientWidth = 700
|
||||
TabOrder = 1
|
||||
object btnLoadSpreadsheet: TButton
|
||||
Left = 312
|
||||
Left = 304
|
||||
Height = 25
|
||||
Top = 24
|
||||
Top = 8
|
||||
Width = 75
|
||||
Caption = 'Load'
|
||||
OnClick = btnLoadSpreadsheetClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object editSourceFile: TFileNameEdit
|
||||
Left = 146
|
||||
Left = 136
|
||||
Height = 21
|
||||
Top = 24
|
||||
Top = 8
|
||||
Width = 136
|
||||
DialogOptions = []
|
||||
FilterIndex = 0
|
||||
@ -50,10 +51,29 @@ object lazfpsmainform: Tlazfpsmainform
|
||||
object Label2: TLabel
|
||||
Left = 8
|
||||
Height = 15
|
||||
Top = 30
|
||||
Top = 14
|
||||
Width = 116
|
||||
Caption = 'Source Spreadsheet:'
|
||||
ParentColor = False
|
||||
end
|
||||
object buttonReadCellInfo: TButton
|
||||
Left = 384
|
||||
Height = 25
|
||||
Top = 8
|
||||
Width = 120
|
||||
Caption = 'Read Cell Info'
|
||||
OnClick = buttonReadCellInfoClick
|
||||
TabOrder = 2
|
||||
end
|
||||
object memoCellData: TMemo
|
||||
Left = 512
|
||||
Height = 64
|
||||
Top = 8
|
||||
Width = 182
|
||||
Lines.Strings = (
|
||||
'memoCellData'
|
||||
)
|
||||
TabOrder = 3
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,10 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, Grids, EditBtn, ExtCtrls, ComCtrls, fpspreadsheetchart,
|
||||
fpspreadsheetgrid, TAGraph, TASeries;
|
||||
fpspreadsheetgrid, TAGraph, TASeries, TypInfo,
|
||||
// FPSpreadsheet and supported formats
|
||||
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument
|
||||
;
|
||||
|
||||
type
|
||||
|
||||
@ -15,17 +18,22 @@ type
|
||||
|
||||
Tlazfpsmainform = class(TForm)
|
||||
btnLoadSpreadsheet: TButton;
|
||||
buttonReadCellInfo: TButton;
|
||||
editSourceFile: TFileNameEdit;
|
||||
Label2: TLabel;
|
||||
memoCellData: TMemo;
|
||||
pagesSheets: TPageControl;
|
||||
Panel1: TPanel;
|
||||
procedure btnLoadSpreadsheetClick(Sender: TObject);
|
||||
procedure buttonReadCellInfoClick(Sender: TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDestroy(Sender: TObject);
|
||||
private
|
||||
{ private declarations }
|
||||
public
|
||||
{ public declarations }
|
||||
Worksheets: array of TsWorksheetGrid;
|
||||
Workbook: TsWorkbook;
|
||||
procedure DeleteAllSheets();
|
||||
end;
|
||||
|
||||
@ -34,17 +42,12 @@ var
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
// FPSpreadsheet and supported formats
|
||||
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument;
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ Tlazfpsmainform }
|
||||
|
||||
procedure Tlazfpsmainform.btnLoadSpreadsheetClick(Sender: TObject);
|
||||
var
|
||||
lWorkbook: TsWorkbook;
|
||||
lWorksheetCount: Cardinal;
|
||||
lCurPage: TTabSheet;
|
||||
lCurWorksheet: TsWorksheet;
|
||||
@ -52,19 +55,17 @@ var
|
||||
begin
|
||||
if editSourceFile.Text = '' then Exit;
|
||||
|
||||
lWorkbook := TsWorkbook.Create;
|
||||
try
|
||||
lWorkbook.ReadFromFile(editSourceFile.Text);
|
||||
Workbook.ReadFromFile(editSourceFile.Text);
|
||||
|
||||
DeleteAllSheets();
|
||||
|
||||
lWorksheetCount := lWorkbook.GetWorksheetCount();
|
||||
lWorksheetCount := Workbook.GetWorksheetCount();
|
||||
SetLength(Worksheets, lWorksheetCount);
|
||||
for i := 0 to lWorksheetCount-1 do
|
||||
begin
|
||||
pagesSheets.AddTabSheet();
|
||||
lCurPage := pagesSheets.Pages[i];
|
||||
lCurWorksheet := lWorkbook.GetWorksheetByIndex(i);
|
||||
lCurWorksheet := Workbook.GetWorksheetByIndex(i);
|
||||
|
||||
Worksheets[i] := TsWorksheetGrid.Create(nil);
|
||||
Worksheets[i].Parent := lCurPage;
|
||||
@ -73,9 +74,29 @@ begin
|
||||
Worksheets[i].LoadFromWorksheet(lCurWorksheet);
|
||||
lCurPage.Caption := lCurWorksheet.Name;
|
||||
end;
|
||||
finally
|
||||
lWorkbook.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure Tlazfpsmainform.buttonReadCellInfoClick(Sender: TObject);
|
||||
var
|
||||
lX, lY, lCurTab: LongInt;
|
||||
lCurWorksheet: TsWorksheet;
|
||||
lCurCell: PCell;
|
||||
begin
|
||||
lCurTab := pagesSheets.TabIndex;
|
||||
lX := Worksheets[lCurTab].Selection.Left;
|
||||
lY := Worksheets[lCurTab].Selection.Top;
|
||||
lCurWorksheet := Workbook.GetWorksheetByIndex(lCurTab);
|
||||
lCurCell := lCurWorksheet.GetCell(lX, lY);
|
||||
memoCellData.Lines.Text := '';
|
||||
memoCellData.Lines.Add(Format('Col: %d Row: %d (zero-based)', [lX, lY]));
|
||||
memoCellData.Lines.Add(Format('ContentType: %s', [GetEnumName(TypeInfo(TCellContentType), integer(lCurCell^.ContentType))]));
|
||||
memoCellData.Lines.Add(Format('NumberValue: %f', [lCurCell^.NumberValue]));
|
||||
memoCellData.Lines.Add(Format('UTF8StringValue: %s', [lCurCell^.UTF8StringValue]));
|
||||
//memoCellData.Lines.Add(Format('DateTimeValue: %s', [lCurCell^.DateTimeValue]));
|
||||
//memoCellData.Lines.Add(Format('UsedFormattingFields: %f', [lCurCell^.NumberValue]));
|
||||
memoCellData.Lines.Add(Format('TextRotation: %s', [GetEnumName(TypeInfo(TsTextRotation), integer(lCurCell^.TextRotation))]));
|
||||
//memoCellData.Lines.Add(Format('Border: %f', [lCurCell^.NumberValue]));
|
||||
memoCellData.Lines.Add(Format('BackgroundColor: %s', [GetEnumName(TypeInfo(TsColor), integer(lCurCell^.BackgroundColor))]));
|
||||
end;
|
||||
|
||||
procedure Tlazfpsmainform.DeleteAllSheets;
|
||||
@ -92,8 +113,14 @@ end;
|
||||
|
||||
procedure Tlazfpsmainform.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Workbook := TsWorkbook.Create;
|
||||
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
|
||||
end;
|
||||
|
||||
procedure Tlazfpsmainform.FormDestroy(Sender: TObject);
|
||||
begin
|
||||
Workbook.Free;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user