This commit is contained in:
csh
2022-12-30 10:49:51 +08:00
parent 88aa334c7a
commit ee77e920b3
18 changed files with 605 additions and 287 deletions
+32 -28
View File
@@ -1,6 +1,8 @@
class(xlsxXml).CodePage('中文');
testCount := 0;
sheetName := "hello";
sheetName2 := "world";
sheetName := "你好";
sheetName2 := "中文";
// OpenFile
excel := new TSExcelFile();
@@ -25,30 +27,41 @@ PrintInfo("NewFile", err, errmsg);
name := excel.FileName();
println("[success] name = {}", name);
// GetSheet
sheets := excel.GetSheets();
println("[success] sheets = {}", sheets);
// GetSheetsCount
sheetCount := excel.GetSheetsCount();
println("[success] GetSheetsCount = {}", sheetCount);
// SetSheetName
[err, errmsg] := excel.SetSheetName("sheet1", sheetName);
PrintInfo("SetSheetName", err, errmsg);
excel.SetSheetName("sheet1", sheetName);
println("[success] SetSheetName");
// GetSheetName
sheetName := excel.GetSheetName(0);
println("[success] GetSheetName = {}", sheetName);
Name := excel.GetSheetName(0);
println("[success] GetSheetName = {}", Name);
// NewSheet
[err, errmsg] := excel.NewSheet(sheetName2);
PrintInfo("NewSheet", err, errmsg);
excel.NewSheet(sheetName2);
println("[success] NewSheet");
// GetSheets
sheets := excel.GetSheets();
println("[success] sheets = {}", sheets);
// DeleteSheet
[err, errmsg] := excel.NewSheet("test1");
//[err, errmsg] := excel.DeleteSheet("test1");
//PrintInfo("DeleteSheet", err, errmsg);
excel.NewSheet("test1");
excel.DeleteSheet("test1");
println("[success] DeleteSheet");
// SetCellValue
excel.SetCellValue(sheetName, "A1", 100);
excel.SetCellValue(sheetName, "F1", "中文的壹佰");
println("[success] SetCellValue");
// GetCellValue
[err, errmsg] := excel.GetCellValue(sheetName, "A1");
PrintInfo("GetCellValue A1 ", err, errmsg);
[err, errmsg] := excel.GetCellValue(sheetName, "F1");
PrintInfo("GetCellValue F1 ", err, errmsg);
// TotalCols
totalCols := excel.TotalCols(sheetName);
@@ -58,17 +71,9 @@ println("[success] TotalCols = {}", totalCols);
totalRows := excel.TotalRows(sheetName);
println("[success] TotalRows = {}", totalRows);
// SetCellValue
flag := excel.SetCellValue(sheetName, "A1", 100);
println("[success] SetCellValue = ", flag);
// GetCellValue
[err, errmsg] := excel.GetCellValue(sheetName, "A1");
PrintInfo("GetCellValue", err, errmsg);
// SetCellRichText
richText := TOfficeObj('TRichtext');
text1 := richText.AddText('Hello');
text1 := richText.AddText('Hello 你好');
text1.Font.Size := 35;
text1.Font.Color := "FFF000";
text2 := richText.AddText(" World");
@@ -77,10 +82,9 @@ text2.Font.Bold := true;
excel.SetCellRichText(sheetName, "A2", richText);
text2.Text := "python";
excel.SetCellRichText(sheetName, "A3", richText);
println("[success] SetCellRichText");
// GetCellRichText
arr := excel.GetCellRichText(sheetName, "A3");
arr := excel.GetCellRichText(sheetName, "A2");
println("[success] GetCellRichText = {}", arr);
// ClearCell
@@ -192,8 +196,6 @@ excel.NewSheet('Sheet1');
[err, errinfo] := excel.InsertTable("Sheet1","A5",data, true);
chart1 := excel.AddChart('Sheet1', 'A11:G30', chart);
println("[success] AddChart");
[err, errmsg] := excel.saveas("", "d:\\temp\\test.xlsx");
println("saveas : {}", err);
// GetCharts
[err, charts] := excel.GetCharts('Sheet1');
@@ -443,6 +445,8 @@ shape_format.EndColOff := 7653;
shape_format.BegRowOff := 55577;
shape_format.EndRowOff := 66675;
shape_type := "roundRect";
//excel.AddShape(sheetName2, "A15", "C17", shape_type, shape_format);
//println("[success] AddShape");
// SetCoreProps
core := TOfficeObj('TCoreProperty');