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"/>
|
<UnitName Value="lazspreadsheet"/>
|
||||||
</Unit0>
|
</Unit0>
|
||||||
<Unit1>
|
<Unit1>
|
||||||
<Filename Value="../../components/fpspreadsheet/examples/lazspreadsheet/about.pas"/>
|
<Filename Value="about.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="Form1"/>
|
<ComponentName Value="Form1"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
@ -53,7 +53,7 @@
|
|||||||
<UnitName Value="about"/>
|
<UnitName Value="about"/>
|
||||||
</Unit1>
|
</Unit1>
|
||||||
<Unit2>
|
<Unit2>
|
||||||
<Filename Value="../../components/fpspreadsheet/examples/lazspreadsheet/mainform.pas"/>
|
<Filename Value="mainform.pas"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<ComponentName Value="lazfpsmainform"/>
|
<ComponentName Value="lazfpsmainform"/>
|
||||||
<HasResources Value="True"/>
|
<HasResources Value="True"/>
|
||||||
|
@ -3,41 +3,42 @@ object lazfpsmainform: Tlazfpsmainform
|
|||||||
Height = 401
|
Height = 401
|
||||||
Top = 170
|
Top = 170
|
||||||
Width = 700
|
Width = 700
|
||||||
Caption = 'FPSpreadsheet Chart Example'
|
Caption = 'LazSpreadsheet'
|
||||||
ClientHeight = 401
|
ClientHeight = 401
|
||||||
ClientWidth = 700
|
ClientWidth = 700
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
|
OnDestroy = FormDestroy
|
||||||
LCLVersion = '1.1'
|
LCLVersion = '1.1'
|
||||||
object pagesSheets: TPageControl
|
object pagesSheets: TPageControl
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 343
|
Height = 321
|
||||||
Top = 58
|
Top = 80
|
||||||
Width = 700
|
Width = 700
|
||||||
Align = alClient
|
Align = alClient
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object Panel1: TPanel
|
object Panel1: TPanel
|
||||||
Left = 0
|
Left = 0
|
||||||
Height = 58
|
Height = 80
|
||||||
Top = 0
|
Top = 0
|
||||||
Width = 700
|
Width = 700
|
||||||
Align = alTop
|
Align = alTop
|
||||||
ClientHeight = 58
|
ClientHeight = 80
|
||||||
ClientWidth = 700
|
ClientWidth = 700
|
||||||
TabOrder = 1
|
TabOrder = 1
|
||||||
object btnLoadSpreadsheet: TButton
|
object btnLoadSpreadsheet: TButton
|
||||||
Left = 312
|
Left = 304
|
||||||
Height = 25
|
Height = 25
|
||||||
Top = 24
|
Top = 8
|
||||||
Width = 75
|
Width = 75
|
||||||
Caption = 'Load'
|
Caption = 'Load'
|
||||||
OnClick = btnLoadSpreadsheetClick
|
OnClick = btnLoadSpreadsheetClick
|
||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
end
|
end
|
||||||
object editSourceFile: TFileNameEdit
|
object editSourceFile: TFileNameEdit
|
||||||
Left = 146
|
Left = 136
|
||||||
Height = 21
|
Height = 21
|
||||||
Top = 24
|
Top = 8
|
||||||
Width = 136
|
Width = 136
|
||||||
DialogOptions = []
|
DialogOptions = []
|
||||||
FilterIndex = 0
|
FilterIndex = 0
|
||||||
@ -50,10 +51,29 @@ object lazfpsmainform: Tlazfpsmainform
|
|||||||
object Label2: TLabel
|
object Label2: TLabel
|
||||||
Left = 8
|
Left = 8
|
||||||
Height = 15
|
Height = 15
|
||||||
Top = 30
|
Top = 14
|
||||||
Width = 116
|
Width = 116
|
||||||
Caption = 'Source Spreadsheet:'
|
Caption = 'Source Spreadsheet:'
|
||||||
ParentColor = False
|
ParentColor = False
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
@ -7,7 +7,10 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
StdCtrls, Grids, EditBtn, ExtCtrls, ComCtrls, fpspreadsheetchart,
|
StdCtrls, Grids, EditBtn, ExtCtrls, ComCtrls, fpspreadsheetchart,
|
||||||
fpspreadsheetgrid, TAGraph, TASeries;
|
fpspreadsheetgrid, TAGraph, TASeries, TypInfo,
|
||||||
|
// FPSpreadsheet and supported formats
|
||||||
|
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument
|
||||||
|
;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -15,17 +18,22 @@ type
|
|||||||
|
|
||||||
Tlazfpsmainform = class(TForm)
|
Tlazfpsmainform = class(TForm)
|
||||||
btnLoadSpreadsheet: TButton;
|
btnLoadSpreadsheet: TButton;
|
||||||
|
buttonReadCellInfo: TButton;
|
||||||
editSourceFile: TFileNameEdit;
|
editSourceFile: TFileNameEdit;
|
||||||
Label2: TLabel;
|
Label2: TLabel;
|
||||||
|
memoCellData: TMemo;
|
||||||
pagesSheets: TPageControl;
|
pagesSheets: TPageControl;
|
||||||
Panel1: TPanel;
|
Panel1: TPanel;
|
||||||
procedure btnLoadSpreadsheetClick(Sender: TObject);
|
procedure btnLoadSpreadsheetClick(Sender: TObject);
|
||||||
|
procedure buttonReadCellInfoClick(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
|
procedure FormDestroy(Sender: TObject);
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
public
|
public
|
||||||
{ public declarations }
|
{ public declarations }
|
||||||
Worksheets: array of TsWorksheetGrid;
|
Worksheets: array of TsWorksheetGrid;
|
||||||
|
Workbook: TsWorkbook;
|
||||||
procedure DeleteAllSheets();
|
procedure DeleteAllSheets();
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -34,17 +42,12 @@ var
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
|
||||||
// FPSpreadsheet and supported formats
|
|
||||||
fpspreadsheet, xlsbiff8, xlsbiff5, xlsbiff2, xlsxooxml, fpsopendocument;
|
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
{ Tlazfpsmainform }
|
{ Tlazfpsmainform }
|
||||||
|
|
||||||
procedure Tlazfpsmainform.btnLoadSpreadsheetClick(Sender: TObject);
|
procedure Tlazfpsmainform.btnLoadSpreadsheetClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
lWorkbook: TsWorkbook;
|
|
||||||
lWorksheetCount: Cardinal;
|
lWorksheetCount: Cardinal;
|
||||||
lCurPage: TTabSheet;
|
lCurPage: TTabSheet;
|
||||||
lCurWorksheet: TsWorksheet;
|
lCurWorksheet: TsWorksheet;
|
||||||
@ -52,32 +55,50 @@ var
|
|||||||
begin
|
begin
|
||||||
if editSourceFile.Text = '' then Exit;
|
if editSourceFile.Text = '' then Exit;
|
||||||
|
|
||||||
lWorkbook := TsWorkbook.Create;
|
Workbook.ReadFromFile(editSourceFile.Text);
|
||||||
try
|
|
||||||
lWorkbook.ReadFromFile(editSourceFile.Text);
|
|
||||||
|
|
||||||
DeleteAllSheets();
|
DeleteAllSheets();
|
||||||
|
|
||||||
lWorksheetCount := lWorkbook.GetWorksheetCount();
|
lWorksheetCount := Workbook.GetWorksheetCount();
|
||||||
SetLength(Worksheets, lWorksheetCount);
|
SetLength(Worksheets, lWorksheetCount);
|
||||||
for i := 0 to lWorksheetCount-1 do
|
for i := 0 to lWorksheetCount-1 do
|
||||||
begin
|
begin
|
||||||
pagesSheets.AddTabSheet();
|
pagesSheets.AddTabSheet();
|
||||||
lCurPage := pagesSheets.Pages[i];
|
lCurPage := pagesSheets.Pages[i];
|
||||||
lCurWorksheet := lWorkbook.GetWorksheetByIndex(i);
|
lCurWorksheet := Workbook.GetWorksheetByIndex(i);
|
||||||
|
|
||||||
Worksheets[i] := TsWorksheetGrid.Create(nil);
|
Worksheets[i] := TsWorksheetGrid.Create(nil);
|
||||||
Worksheets[i].Parent := lCurPage;
|
Worksheets[i].Parent := lCurPage;
|
||||||
Worksheets[i].Align := alClient;
|
Worksheets[i].Align := alClient;
|
||||||
//Worksheets[i].Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
//Worksheets[i].Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goEditing, goSmoothScroll]
|
||||||
Worksheets[i].LoadFromWorksheet(lCurWorksheet);
|
Worksheets[i].LoadFromWorksheet(lCurWorksheet);
|
||||||
lCurPage.Caption := lCurWorksheet.Name;
|
lCurPage.Caption := lCurWorksheet.Name;
|
||||||
end;
|
|
||||||
finally
|
|
||||||
lWorkbook.Free;
|
|
||||||
end;
|
end;
|
||||||
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;
|
procedure Tlazfpsmainform.DeleteAllSheets;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -92,8 +113,14 @@ end;
|
|||||||
|
|
||||||
procedure Tlazfpsmainform.FormCreate(Sender: TObject);
|
procedure Tlazfpsmainform.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
|
Workbook := TsWorkbook.Create;
|
||||||
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
|
editSourceFile.InitialDir := ExtractFilePath(ParamStr(0));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure Tlazfpsmainform.FormDestroy(Sender: TObject);
|
||||||
|
begin
|
||||||
|
Workbook.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user