v1.2.2
This commit is contained in:
+39
-33
@@ -56,9 +56,11 @@ style.Border.Top.LineStyle := "double";
|
||||
style.Border.Top.Color := "FF0000";
|
||||
style.Alignment.Horizontal := "center";
|
||||
style.Alignment.Vertical := "center";
|
||||
style.Fill.Gradient.Shading := 3;
|
||||
style.Fill.Gradient.Color1 := "FFFFFF";
|
||||
style.Fill.Gradient.Color2 := "E0EBF5";
|
||||
style.Fill.Gradient.Degree := 0;
|
||||
style.Fill.Gradient.Stop1.Position := 0;
|
||||
style.Fill.Gradient.Stop1.Color := "FFFFFF";
|
||||
style.Fill.Gradient.Stop2.Position := 1;
|
||||
style.Fill.Gradient.Stop2.Color := "E0EBF5";
|
||||
|
||||
styleId := file.NewStyle(style);
|
||||
PrintSuccess("NewStyle", testing++);
|
||||
@@ -223,9 +225,15 @@ Begin
|
||||
style.Font.Size := 14;
|
||||
style.Font.Bold := True;
|
||||
style.Font.UnderLine := 'singleAccounting';
|
||||
style.Fill.Gradient.Shading := 16;
|
||||
style.Fill.Gradient.Color1 := 'A3ECFB';
|
||||
style.Fill.Gradient.Color2 := '626AD8';
|
||||
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.Stop1.Position := 0;
|
||||
style.Fill.Gradient.Stop1.Color := 'A3ECFB';
|
||||
style.Fill.Gradient.Stop2.Position := 1;
|
||||
style.Fill.Gradient.Stop2.Color := '626AD8';
|
||||
styleid1 := excel.NewStyle(style);
|
||||
|
||||
style := TOfficeObj('TStyle');
|
||||
@@ -487,9 +495,11 @@ style.NumberFormat.FormatCode := '#,##0.000_ ';
|
||||
//style.Fill.Pattern.PatternType := 'solid';
|
||||
//style.Fill.Pattern.ForegroundColor := 'FF6699FF';
|
||||
//style.Fill.Pattern.BackgroundColor := 'FFFF0000';
|
||||
style.Fill.Gradient.ThemeColor1 := 0;
|
||||
style.Fill.Gradient.ThemeColor2 := 4;
|
||||
style.Fill.Gradient.Shading := 1;
|
||||
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.Protection.Hide := 1;
|
||||
style.Protection.Lock := 1;
|
||||
";
|
||||
@@ -596,30 +606,26 @@ style.Protection.Lock := 1;
|
||||
('ObjName': 'TGradient',
|
||||
'Desc': ('TGradient有以下属性: '),
|
||||
'AttrInfo': (
|
||||
('attrName': '', 'type': '', 'desc': '{颜色1}:渐变的第一种颜色,{Color1}和{ThemeColor1}只能设置一种', 'value': array()),
|
||||
('attrName': 'Color1', 'type': 'string', 'desc': 'RGB颜色', 'value': array()),
|
||||
('attrName': 'ThemeColor1', 'type': 'int', 'desc': '主题颜色', 'value': array()),
|
||||
('attrName': '', 'type': '', 'desc': '{颜色2}:渐变的第一种颜色,{Color2}和{ThemeColor2}只能设置一种', 'value': array()),
|
||||
('attrName': 'Color2', 'type': 'string', 'desc': 'RGB颜色', 'value': array()),
|
||||
('attrName': 'ThemeColor2', 'type': 'int', 'desc': '主题颜色', 'value': array()),
|
||||
('attrName': 'Shading', 'type': 'int', 'desc': '底纹样式', 'value': array('0: 水平渐变,颜色1从上到下渐变到颜色2', '1: 水平渐变,颜色2从上到下渐变到颜色1',
|
||||
'2: 水平渐变,三层颜色,颜色1从上渐变到中间颜色2,再从颜色2渐变到底部颜色1',
|
||||
'3: 垂直渐变,颜色1从左到右渐变到颜色2',
|
||||
'4: 垂直渐变,颜色2从右到左渐变到颜色1',
|
||||
'5: 垂直渐变,三层颜色,颜色1从左渐变到中间颜色2,再从颜色2渐变到右边颜色1',
|
||||
'6: 斜上渐变,颜色1左上渐变到右下颜色2',
|
||||
'7: 斜上渐变,颜色2左上渐变到右下颜色1',
|
||||
'8: 斜上渐变,三层颜色,颜色1从左上渐变到对角线颜色2,再从颜色2渐变到右下颜色1',
|
||||
'9: 斜下渐变,颜色1右上渐变到左下颜色2',
|
||||
'10: 斜下渐变,颜色2左上渐变到右下颜色1',
|
||||
'11: 斜下渐变,三层颜色,颜色1从左上渐变到对角线颜色2,再从颜色2渐变到右下颜色1',
|
||||
'12: 角部辐射渐变,颜色1左上角辐射渐变到右下角2',
|
||||
'13: 角部辐射渐变,颜色1右上角辐射渐变到左下角颜色2',
|
||||
'14: 角部辐射渐变,颜色1左下角辐射渐变到右上角2',
|
||||
'15: 角部辐射渐变,颜色1右下角辐射渐变到左上角颜色2',
|
||||
'16: 中心辐射渐变,颜色1从中心向四周辐射到颜色2',
|
||||
)),
|
||||
),
|
||||
('attrName': 'Degree', 'type': 'int', 'desc': '渐变的角度(水平、垂直、斜上、斜下)', 'value': array(0, 45, 90, 135, 180, 225, 270, 315)),
|
||||
('attrName': 'Type', 'type': 'string', 'desc': '辐射渐变,采用辐射渐变时,不需设置{Degree}', 'value': array('path')),
|
||||
('attrName': 'Left', 'type': 'string', 'desc': '辐射渐变时需设置属性', 'value': array()),
|
||||
('attrName': 'Right', 'type': 'string', 'desc': '辐射渐变时需设置属性', 'value': array()),
|
||||
('attrName': 'Top', 'type': 'string', 'desc': '辐射渐变时需设置属性', 'value': array()),
|
||||
('attrName': 'Bottom', 'type': 'string', 'desc': '辐射渐变时需设置属性', 'value': array()),
|
||||
('attrName': 'Stop1', 'type': 'class - TStop', 'desc': '渐变点需要设置的信息', 'value': array()),
|
||||
('attrName': 'Stop2', 'type': 'class - TStop', 'desc': '渐变点需要设置的信息', 'value': array()),
|
||||
('attrName': 'Stop3', 'type': 'class - TStop', 'desc': '渐变点需要设置的信息', 'value': array()),
|
||||
),
|
||||
'Demo': '',
|
||||
),
|
||||
('ObjName': 'TStop',
|
||||
'Desc': ('TStop有以下属性: '),
|
||||
'AttrInfo': (
|
||||
('attrName': 'Position', 'type': 'double', 'desc': '', 'value': array()),
|
||||
('attrName': 'Color', 'type': 'string', 'desc': 'RGB颜色', 'value': array()),
|
||||
('attrName': 'ThemeColor', 'type': 'int', 'desc': '主题颜色', 'value': array()),
|
||||
('attrName': 'ThemeColorTint', 'type': 'int', 'desc': '主题颜色的色调', 'value': array()),
|
||||
),
|
||||
'Demo': '',
|
||||
),
|
||||
('ObjName': 'TProtection',
|
||||
|
||||
+107
-23
@@ -1,8 +1,8 @@
|
||||
TOfficeApi().CodePage('中文');
|
||||
TOfficeApi().CodePage('中文');
|
||||
|
||||
testCount := 0;
|
||||
sheetName := "你好";
|
||||
sheetName2 := "中文";
|
||||
sheetName := "你好";
|
||||
sheetName2 := "中文";
|
||||
|
||||
// OpenFile
|
||||
excel := new TSExcelFile();
|
||||
@@ -43,6 +43,14 @@ 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);
|
||||
@@ -54,7 +62,7 @@ println("[success] DeleteSheet");
|
||||
|
||||
// SetCellValue
|
||||
excel.SetCellValue(sheetName, "A1", 100);
|
||||
excel.SetCellValue(sheetName, "F1", "中文的壹佰");
|
||||
excel.SetCellValue(sheetName, "F1", "中文的壹佰");
|
||||
println("[success] SetCellValue");
|
||||
|
||||
// GetCellValue
|
||||
@@ -63,6 +71,10 @@ 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);
|
||||
@@ -73,7 +85,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");
|
||||
@@ -93,7 +105,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
|
||||
@@ -105,7 +117,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);
|
||||
@@ -219,6 +231,12 @@ 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);
|
||||
@@ -231,7 +249,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";
|
||||
@@ -259,9 +277,11 @@ style.NumberFormat.FormatCode := "#,##0.000_ ";
|
||||
//style.Fill.Pattern.PatternType := "solid";
|
||||
//style.Fill.Pattern.ForegroundColor := "FF6699FF";
|
||||
//style.Fill.Pattern.BackgroundColor := "FFFF0000";
|
||||
style.Fill.Gradient.ThemeColor1 := 0;
|
||||
style.Fill.Gradient.ThemeColor2 := 4;
|
||||
style.Fill.Gradient.Shading := 1;
|
||||
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.Protection.Hide := 1;
|
||||
style.Protection.Lock := 1;
|
||||
|
||||
@@ -277,6 +297,31 @@ 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;
|
||||
@@ -332,8 +377,8 @@ println("[success] SetPageMargins");
|
||||
// GetPageMargins
|
||||
margins := excel.GetPageMargins(sheetName2);
|
||||
println("[success] GetPageMargins top = {}, bottom = {}, left = {}, right = {}, header = {}, footer = {}",
|
||||
margins.Value('Top'), margins.Value('Bottom'), margins.Value('Left'), margins.Value('Right'),
|
||||
margins.Value('Header'), margins.Value('Footer'));
|
||||
margins.Top, margins.Bottom, margins.Left, margins.Right,
|
||||
margins.Header, margins.Footer);
|
||||
|
||||
// MergeCell
|
||||
excel.SetCellStyle(sheetName2, "A4", "A4", styleid1);
|
||||
@@ -372,6 +417,7 @@ println("[success] SetPane");
|
||||
pageLayout := TOfficeObj('TPageLayout');
|
||||
pageLayout.FitToWidth := 10;
|
||||
pageLayout.FitToHeight := 10;
|
||||
pageLayout.UseFirstPageNumber := true;
|
||||
pageLayout.FirstPageNumber := 5;
|
||||
pageLayout.Orientation := "portrait";
|
||||
pageLayout.BlackAndWhite := true;
|
||||
@@ -402,8 +448,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");
|
||||
|
||||
@@ -431,12 +477,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;
|
||||
@@ -466,9 +512,9 @@ println("[success] AddShape");
|
||||
|
||||
// SetCoreProps
|
||||
core := TOfficeObj('TCoreProperty');
|
||||
core.Title := "标题";
|
||||
core.Subject := "主题";
|
||||
core.Creator := "作者";
|
||||
core.Title := "标题";
|
||||
core.Subject := "主题";
|
||||
core.Creator := "作者";
|
||||
excel.SetCoreProps(core);
|
||||
|
||||
// GetCoreProps
|
||||
@@ -484,8 +530,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");
|
||||
|
||||
@@ -519,7 +565,7 @@ println("[success] ProtectSheet");
|
||||
|
||||
// SetDefaultFont
|
||||
font := tofficeobj('tfont');
|
||||
font.Name := '黑体';
|
||||
font.Name := '黑体';
|
||||
font.Size := 13;
|
||||
font.ThemeColor := 1;
|
||||
excel.SetDefaultFont(font);
|
||||
@@ -528,6 +574,44 @@ 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