v1.2.3
This commit is contained in:
+6
-6
@@ -227,13 +227,13 @@ Begin
|
||||
style.Font.UnderLine := 'singleAccounting';
|
||||
style.Fill.Gradient.Type := 'path';
|
||||
style.Fill.Gradient.Left := 0.5;
|
||||
style.Fill.Gradient.Right := 0.5;
|
||||
style.Fill.Gradient.Top := 0.5;
|
||||
style.Fill.Gradient.Bottom := 0.5;
|
||||
style.Fill.Gradient.Left := 0.5;
|
||||
style.Fill.Gradient.Left := 0.5;
|
||||
style.Fill.Gradient.Left := 0.5;
|
||||
style.Fill.Gradient.Stop1.Position := 0;
|
||||
style.Fill.Gradient.Stop1.Color := 'A3ECFB';
|
||||
style.Fill.Gradient.Stop1.Color := "A3ECFB";
|
||||
style.Fill.Gradient.Stop2.Position := 1;
|
||||
style.Fill.Gradient.Stop2.Color := '626AD8';
|
||||
style.Fill.Gradient.Stop2.Color := "626AD8";
|
||||
styleid1 := excel.NewStyle(style);
|
||||
|
||||
style := TOfficeObj('TStyle');
|
||||
@@ -552,7 +552,7 @@ style.Protection.Lock := 1;
|
||||
('attrName': '', 'type': 'double', 'desc': '{颜色}:{Color}和{ThemeColor}只能设置一种', 'value': array()),
|
||||
('attrName': 'Color', 'type': 'string', 'desc': 'RGB颜色,如"A020F0"', 'value': array()),
|
||||
('attrName': 'ThemeColor', 'type': 'int', 'desc': '主题颜色', 'value': array()),
|
||||
('attrName': 'Underline', 'type': 'string', 'desc': '下划线', 'value': array('"double": 双下划线', '"singleAccounting": 会计单下划线', '"doubleAccounting": 会计双下划线')),
|
||||
('attrName': 'Underline', 'type': 'string', 'desc': '下划线', 'value': array('"none": 无', '"single": 单下划线', '"double": 双下划线', '"singleAccounting": 会计单下划线', '"doubleAccounting": 会计双下划线')),
|
||||
),
|
||||
'Demo': '',
|
||||
),
|
||||
|
||||
+23
-107
@@ -1,8 +1,8 @@
|
||||
TOfficeApi().CodePage('中文');
|
||||
TOfficeApi().CodePage('中文');
|
||||
|
||||
testCount := 0;
|
||||
sheetName := "你好";
|
||||
sheetName2 := "中文";
|
||||
sheetName := "你好";
|
||||
sheetName2 := "中文";
|
||||
|
||||
// OpenFile
|
||||
excel := new TSExcelFile();
|
||||
@@ -43,14 +43,6 @@ println("[success] GetSheetName = {}", Name);
|
||||
excel.NewSheet(sheetName2);
|
||||
println("[success] NewSheet");
|
||||
|
||||
// NewSheet
|
||||
excel.NewSheet(sheetName, 'sheet_copy');
|
||||
println("[success] NewSheet2");
|
||||
|
||||
// InsertSheet
|
||||
excel.InsertSheet(sheetName, sheetName + 'before');
|
||||
println("[success] NewSheet2");
|
||||
|
||||
// GetSheets
|
||||
sheets := excel.GetSheets();
|
||||
println("[success] sheets = {}", sheets);
|
||||
@@ -62,7 +54,7 @@ println("[success] DeleteSheet");
|
||||
|
||||
// SetCellValue
|
||||
excel.SetCellValue(sheetName, "A1", 100);
|
||||
excel.SetCellValue(sheetName, "F1", "中文的壹佰");
|
||||
excel.SetCellValue(sheetName, "F1", "中文的壹佰");
|
||||
println("[success] SetCellValue");
|
||||
|
||||
// GetCellValue
|
||||
@@ -71,10 +63,6 @@ PrintInfo("GetCellValue A1 ", err, errmsg);
|
||||
[err, errmsg] := excel.GetCellValue(sheetName, "F1");
|
||||
PrintInfo("GetCellValue F1 ", err, errmsg);
|
||||
|
||||
// GetCellValue
|
||||
[err, errmsg] := excel.GetCellRawValue(sheetName, "A1");
|
||||
PrintInfo("GetCellRawValue A1 ", err, errmsg);
|
||||
|
||||
// TotalCols
|
||||
totalCols := excel.TotalCols(sheetName);
|
||||
println("[success] TotalCols = {}", totalCols);
|
||||
@@ -85,7 +73,7 @@ println("[success] TotalRows = {}", totalRows);
|
||||
|
||||
// SetCellRichText
|
||||
richText := TOfficeObj('TRichtext');
|
||||
text1 := richText.AddText('Hello 你好');
|
||||
text1 := richText.AddText('Hello 你好');
|
||||
text1.Font.Size := 35;
|
||||
text1.Font.Color := "FFF000";
|
||||
text2 := richText.AddText(" World");
|
||||
@@ -105,7 +93,7 @@ excel.ClearCell(sheetName, "A1");
|
||||
println("[success] ClearCell");
|
||||
|
||||
// SetCellFormula
|
||||
excel.SetCellFormula(sheetName, "A2", "100*50");
|
||||
excel.SetCellFormula(sheetName, "A2", "=100*50");
|
||||
println("[success] SetCellFormula");
|
||||
|
||||
// GetCellFormula
|
||||
@@ -117,7 +105,7 @@ excel.SetSheetRow(sheetName, "C3", array(1, 2, 3, 4, "a", "b"));
|
||||
println("[success] SetSheetRow");
|
||||
|
||||
// InsertTable
|
||||
table := array((1, 2, "你好"), (4, 5, "b"));
|
||||
table := array((1, 2, "你好"), (4, 5, "b"));
|
||||
//table2 := array(("title1" :1, "title2": 2), ("title1": 3, "title2": 4));
|
||||
[err, errmsg] := excel.InsertTable(sheetName, "A5", table);
|
||||
PrintInfo("InsertTable", err, errmsg);
|
||||
@@ -231,12 +219,6 @@ PrintInfo("ColumnNumberToName", err, errmsg);
|
||||
[err, col, row] := excel.CellNameToCoordinates("A2");
|
||||
if not err then println("[success] {} = col : {}, row = {}", "CellNameToCoordinates", col, row);
|
||||
|
||||
// CoordinatesToCellName
|
||||
[err, cell] := excel.CoordinatesToCellName(1, 2, true);
|
||||
println("[success] CoordinatesToCellName, cell = {}", cell);
|
||||
[err, cell] := excel.CoordinatesToCellName(1, 2);
|
||||
println("[success] CoordinatesToCellName, cell = {}", cell);
|
||||
|
||||
// RGBToHSL
|
||||
[h, s, l] := excel.RGBToHSL(255, 15, 33);
|
||||
println("[success] {} = {}, {}, {}", "RGBToHSL", h, s, l);
|
||||
@@ -249,7 +231,7 @@ println("[success] {} = {}, {}, {}", "HSLToRGB", r, g, b);
|
||||
style := TOfficeObj('TStyle');
|
||||
style.Font.Color := "A020F0";
|
||||
style.Font.Size := 22;
|
||||
style.Font.Name := "黑体";
|
||||
style.Font.Name := "黑体";
|
||||
style.Font.Bold := True;
|
||||
style.Font.Charset := "134";
|
||||
style.Font.Script := "subscript";
|
||||
@@ -277,11 +259,9 @@ style.NumberFormat.FormatCode := "#,##0.000_ ";
|
||||
//style.Fill.Pattern.PatternType := "solid";
|
||||
//style.Fill.Pattern.ForegroundColor := "FF6699FF";
|
||||
//style.Fill.Pattern.BackgroundColor := "FFFF0000";
|
||||
style.Fill.Gradient.Degree := 270;
|
||||
style.Fill.Gradient.Stop1.Position := 0;
|
||||
style.Fill.Gradient.Stop1.ThemeColor := 0;
|
||||
style.Fill.Gradient.Stop2.Position := 1;
|
||||
style.Fill.Gradient.Stop2.ThemeColor := 4;
|
||||
style.Fill.Gradient.ThemeColor1 := 0;
|
||||
style.Fill.Gradient.ThemeColor2 := 4;
|
||||
style.Fill.Gradient.Shading := 1;
|
||||
style.Protection.Hide := 1;
|
||||
style.Protection.Lock := 1;
|
||||
|
||||
@@ -297,31 +277,6 @@ println("[success] GetCellStyle = {}", styleid);
|
||||
styleid := excel.GetCellStyle(sheetName, "D4");
|
||||
println("[success] GetCellStyle = {}", styleid);
|
||||
|
||||
style := excel.GetStyle(styleid);
|
||||
println("font.Name = {}", style.Font.Name);
|
||||
println("font.Italic = {}", style.Font.Italic);
|
||||
println("border.left.Color = {}", style.border.left.Color);
|
||||
println("border.Top.LineStyle = {}", style.border.Top.LineStyle);
|
||||
println("border.DiagonalDown = {}", style.border.DiagonalDown);
|
||||
println("numberFormat.FormatCode = {}", style.NumberFormat.FormatCode);
|
||||
println("alignment.vertical = {}", style.Alignment.Vertical);
|
||||
println("alignment.TextRotation = {}", style.Alignment.TextRotation);
|
||||
println("protection.Hide = {}", style.Protection.Hide);
|
||||
println("protection.Lock = {}", style.Protection.Lock);
|
||||
//println("fill.pattern.PatternType = {}", style.Fill.Pattern.PatternType);
|
||||
//println("fill.pattern.ForegroundColor = {}", style.Fill.Pattern.ForegroundColor);
|
||||
println("style.Fill.Gradient.Degree = {}", style.Fill.Gradient.Degree);
|
||||
println("style.Fill.Gradient.Stop1.ThemeColor = {}", style.Fill.Gradient.Stop1.ThemeColor);
|
||||
println("style.Fill.Gradient.Stop2.Position = {}", style.Fill.Gradient.Stop2.Position);
|
||||
|
||||
style.Protection.Hide := 0;
|
||||
style.Protection.Lock := 0;
|
||||
style.Apply();
|
||||
style := excel.GetStyle(styleid);
|
||||
|
||||
println("protection.Hide = {}", style.Protection.Hide);
|
||||
println("protection.Lock = {}", style.Protection.Lock);
|
||||
|
||||
// SetSheetHeaderFooter
|
||||
headerFooter := TOfficeObj("THeaderFooter");
|
||||
headerFooter.DifferentOddEven := true;
|
||||
@@ -377,8 +332,8 @@ println("[success] SetPageMargins");
|
||||
// GetPageMargins
|
||||
margins := excel.GetPageMargins(sheetName2);
|
||||
println("[success] GetPageMargins top = {}, bottom = {}, left = {}, right = {}, header = {}, footer = {}",
|
||||
margins.Top, margins.Bottom, margins.Left, margins.Right,
|
||||
margins.Header, margins.Footer);
|
||||
margins.Value('Top'), margins.Value('Bottom'), margins.Value('Left'), margins.Value('Right'),
|
||||
margins.Value('Header'), margins.Value('Footer'));
|
||||
|
||||
// MergeCell
|
||||
excel.SetCellStyle(sheetName2, "A4", "A4", styleid1);
|
||||
@@ -417,7 +372,6 @@ println("[success] SetPane");
|
||||
pageLayout := TOfficeObj('TPageLayout');
|
||||
pageLayout.FitToWidth := 10;
|
||||
pageLayout.FitToHeight := 10;
|
||||
pageLayout.UseFirstPageNumber := true;
|
||||
pageLayout.FirstPageNumber := 5;
|
||||
pageLayout.Orientation := "portrait";
|
||||
pageLayout.BlackAndWhite := true;
|
||||
@@ -448,8 +402,8 @@ excel.SetCellHyperLink(sheetName2, 'A1', link);
|
||||
link := TOfficeObj('THyperLink');
|
||||
link.LinkType := "external";
|
||||
link.LinkUrl := "https://www.baidu.com";
|
||||
link.Tooltip := "超链接悬浮提示";
|
||||
excel.SetCellValue(sheetName2, 'A2', '超链接');
|
||||
link.Tooltip := "超链接悬浮提示";
|
||||
excel.SetCellValue(sheetName2, 'A2', '超链接');
|
||||
excel.SetCellHyperLink(sheetName2, 'A2', link);
|
||||
println("[success] SetCellHyperLink");
|
||||
|
||||
@@ -477,12 +431,12 @@ println("[success] AddPicture");
|
||||
excel.DeletePicture(sheetName2, 'A1', 'D17');
|
||||
println("[success] DeletePicture");
|
||||
|
||||
// TODO 可能有问题
|
||||
// TODO 可能有问题
|
||||
// AddTable
|
||||
table2 := array(("title1" :1, "title2": 2), ("title1": 3, "title2": 4));
|
||||
excel.InsertTable(sheetName2, "A9", table2, true);
|
||||
tablestyle := TOfficeObj('TTableStyle');
|
||||
tablestyle.TableName := "测试表";
|
||||
tablestyle.TableName := "测试表";
|
||||
tablestyle.TableStyle := "TableStyleMedium2";
|
||||
tablestyle.ShowFirstColumn := True;
|
||||
tablestyle.ShowLastColumn := True;
|
||||
@@ -512,9 +466,9 @@ println("[success] AddShape");
|
||||
|
||||
// SetCoreProps
|
||||
core := TOfficeObj('TCoreProperty');
|
||||
core.Title := "标题";
|
||||
core.Subject := "主题";
|
||||
core.Creator := "作者";
|
||||
core.Title := "标题";
|
||||
core.Subject := "主题";
|
||||
core.Creator := "作者";
|
||||
excel.SetCoreProps(core);
|
||||
|
||||
// GetCoreProps
|
||||
@@ -530,8 +484,8 @@ appProps.Company := "TS";
|
||||
appProps.LinksUpToDate := "true";
|
||||
appProps.HyperlinksChanged := "true";
|
||||
appProps.Version := "1.000";
|
||||
appProps.Manager := "这是主管";
|
||||
//appProps.HyperlinkBase := "这是超链接基础";
|
||||
appProps.Manager := "这是主管";
|
||||
//appProps.HyperlinkBase := "这是超链接基础";
|
||||
excel.SetAppProps(appProps);
|
||||
println("[success] SetAppProps");
|
||||
|
||||
@@ -565,7 +519,7 @@ println("[success] ProtectSheet");
|
||||
|
||||
// SetDefaultFont
|
||||
font := tofficeobj('tfont');
|
||||
font.Name := '黑体';
|
||||
font.Name := '黑体';
|
||||
font.Size := 13;
|
||||
font.ThemeColor := 1;
|
||||
excel.SetDefaultFont(font);
|
||||
@@ -574,44 +528,6 @@ println("[success] SetDefaultFont");
|
||||
tfont := excel.GetDefaultFont();
|
||||
println("[success] GetDefaultFont , name = {}, size = {}, themecolor = {}", tfont.Name, tfont.Size, tfont.ThemeColor);
|
||||
|
||||
calcpr := TOfficeObj('TCalcPr');
|
||||
calcpr.CalcMode := "";
|
||||
calcpr.RefMode := "R1C1";
|
||||
calcpr.Iterate := 1;
|
||||
calcpr.IterateCount := 300;
|
||||
calcpr.IterateDelta := "3E-3";
|
||||
calcpr.CalcOnSave := true;
|
||||
calcpr.ConCurrentCalc := true;
|
||||
calcpr.ConCurrentManualCount := 4;
|
||||
calcpr.FullPrecision := 0;
|
||||
excel.SetCalcOptions(calcpr);
|
||||
println("[success] SetCalcOptions");
|
||||
|
||||
calc := excel.GetCalcOptions();
|
||||
println("[success] GetCalcOptions, CalcMode = {}, RefMode = {}, Iterate = {},
|
||||
IterateCount = {}, IterateDelta = {}, CalcOnSave = {}, conCurrentCalc = {},
|
||||
conCurrentManualCount = {}, FullPrecision = {}", calc.CalcMode, calc.RefMode, calc.Iterate,
|
||||
calc.IterateCount, calc.IterateDelta, calc.CalcOnSave, calc.conCurrentCalc,
|
||||
calc.conCurrentManualCount, calc.FullPrecision);
|
||||
|
||||
excel.SetRowOutlineLevel(sheetName2, 1, 1);
|
||||
excel.SetRowOutlineLevel(sheetName2, 2, 1);
|
||||
println("[success] SetRowOutlineLevel");
|
||||
|
||||
level1 := excel.GetRowOutlineLevel(sheetName2, 1);
|
||||
level2 := excel.GetRowOutlineLevel(sheetName2, 3);
|
||||
|
||||
println("[success] GetRowOutlineLevel, level1 = {}, level2 = {}", level1, level2);
|
||||
|
||||
excel.SetColOutlineLevel(sheetName2, 'A', 1);
|
||||
excel.SetColOutlineLevel(sheetName2, 'B', 2);
|
||||
excel.SetColOutlineLevel(sheetName2, 'C', 1);
|
||||
println("[success] SetColOutlineLevel");
|
||||
|
||||
level1 := excel.GetColOutlineLevel(sheetName2, 'A');
|
||||
level2 := excel.GetColOutlineLevel(sheetName2, 'B');
|
||||
println("[success] GetColOutlineLevel, level1 = {}, level2 = {}", level1, level2);
|
||||
|
||||
[err, errmsg] := excel.saveas("", "d:\\temp\\test.xlsx");
|
||||
println("saveas : {}", err);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user