v1.0.4
This commit is contained in:
+3
-7
@@ -13,14 +13,10 @@ if err then
|
||||
return PrintError("NewFile", err, errinfo);
|
||||
PrintSuccess("NewFile", testing++);
|
||||
|
||||
[err, errinfo] := file.SetSheetName('Sheet1', 'ExcelFile');
|
||||
if err then
|
||||
return PrintError("SetSheetName", err, errinfo);
|
||||
file.SetSheetName('Sheet1', 'ExcelFile');
|
||||
PrintSuccess("SetSheetName", testing++);
|
||||
|
||||
[err, errinfo] := file.NewSheet("Functions");
|
||||
if err then
|
||||
return PrintError("NewSheet", err, errinfo);
|
||||
file.NewSheet("Functions");
|
||||
PrintSuccess("NewSheet", testing++);
|
||||
|
||||
file.SetDefaultSheet('ExcelFile');
|
||||
@@ -140,7 +136,7 @@ End
|
||||
file.SetColWidth('Functions', 'A', 'A', 120);
|
||||
PrintSuccess('SetColWidth', testing++);
|
||||
|
||||
saveName := utf8toansi("d:\\temp\\ExcelFile使用帮助.xlsx");
|
||||
saveName := utf8toansi("ExcelFile使用帮助.xlsx");
|
||||
[err, errinfo] := file.SaveAs('', saveName);
|
||||
if err then
|
||||
return PrintError("SaveAs", err, errinfo);
|
||||
|
||||
+32
-28
@@ -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');
|
||||
|
||||
+22
-15
@@ -64,7 +64,7 @@ _Faq(docx);
|
||||
///目录
|
||||
docx.AddTableContent(paragraphTitle, 1, 3);
|
||||
|
||||
v := docx.SaveAs('', 'TSDocFile-Help.docx');
|
||||
v := docx.SaveAs('', UTF8ToAnsi('DocxFile使用帮助.docx'));
|
||||
println('Test Over!\n Save {}: {},time={}秒', file, v, mtoc);
|
||||
|
||||
//info := GetProfilerInfo(true);
|
||||
@@ -119,7 +119,7 @@ Begin
|
||||
|
||||
//添加段落
|
||||
preface := TOfficeObj('TParagraph');
|
||||
preface.Run.T := '本文档由word_help.tsl脚本,调用本文档中描述的接口自动生成!';
|
||||
preface.Run.SetText( '本文档由word_help.tsl脚本,调用本文档中描述的接口自动生成!' );
|
||||
preface.Format.FirstLineIndent := 220; //指定段落第一行缩进的相对差异的值
|
||||
preface.Format.LeftIndent := 440;//段落左边距
|
||||
preface.Font.Name := '宋体';
|
||||
@@ -154,6 +154,7 @@ Begin
|
||||
|
||||
///TParagraph属性
|
||||
_AddTitle(docx, 'TParagraph属性', 2); //第二级标题
|
||||
attrs := array(('类别':'缺省w:r元素', '接口':'Run', '说明':'TRun对象'));
|
||||
formatObj := new TOfficeObj('TwpPr');
|
||||
_LoadObjectAttributes(formatObj, attrs, '段落属性', 'Format');
|
||||
fontObj := new TOfficeObj('TwrPr');
|
||||
@@ -166,10 +167,16 @@ Begin
|
||||
conf union= _LoadClassInfo(docx.GetPath() + '\\funcext\\TSOffice\\TOfficeObj.tsf', 'DocObject');
|
||||
_AddFunctionHelpInfo(docx, '' $ paragraph $ '.2.', conf, 3);
|
||||
|
||||
///TRun方法
|
||||
_AddTitle(docx, 'TRun方法(段落中w:r元素)', 2);
|
||||
conf := _LoadClassInfo(docx.GetPath() + '\\funcext\\TSOffice\\TOfficeObj.tsf', 'TRun');
|
||||
conf union= _LoadClassInfo(docx.GetPath() + '\\funcext\\TSOffice\\TOfficeObj.tsf', 'DocObject');
|
||||
_AddFunctionHelpInfo(docx, '' $ paragraph $ '.3.', conf, 3);
|
||||
|
||||
///TTabStops对象
|
||||
_AddTitle(docx, 'TTabStops对象', 2);
|
||||
conf := _LoadClassInfo(docx.GetPath() + '\\funcext\\TSOffice\\TOfficeObj.tsf', 'TTabStops');
|
||||
_AddFunctionHelpInfo(docx, '' $ paragraph $ '.3.', conf, 3);
|
||||
_AddFunctionHelpInfo(docx, '' $ paragraph $ '.4.', conf, 3);
|
||||
|
||||
///TabStop属性
|
||||
_AddTitle(docx, 'TTabStop属性', 2); //第二级标题
|
||||
@@ -287,7 +294,7 @@ Begin
|
||||
p1 := TOfficeObj('TParagraph');
|
||||
p1.Format.FirstLineIndent := 220; //指定段落第一行缩进的相对差异的值
|
||||
p1.Format.LeftIndent := 440;//段落左边距
|
||||
p1.Run.AddText('本文档由天软科技制作。');
|
||||
p1.Run.SetText('本文档由天软科技制作。');
|
||||
p1.Run.rPr.Name := '宋体';
|
||||
p1.Run.rPr.Bold := true;
|
||||
p1.Run.rPr.Size := 32;
|
||||
@@ -375,7 +382,7 @@ Begin
|
||||
p1 := TOfficeObj('TParagraph');
|
||||
p1.Format.FirstLineIndent := 220; //指定段落第一行缩进的相对差异的值
|
||||
p1.Format.LeftIndent := 440;//段落左边距
|
||||
p1.Run.T := '插入案例。';
|
||||
p1.Run.SetText( '插入案例。' );
|
||||
p1.Run.rPr.Name := '宋体';
|
||||
p1.Run.rPr.Bold := true;
|
||||
p1.Run.rPr.Size := 32;
|
||||
@@ -394,7 +401,7 @@ Begin
|
||||
p1 := TOfficeObj('TParagraph');
|
||||
p1.Format.FirstLineIndent := 220; //指定段落第一行缩进的相对差异的值
|
||||
p1.Format.LeftIndent := 440;//段落左边距
|
||||
p1.Run.T := '删除修订案例。';
|
||||
p1.Run.SetText( '删除修订案例。' );
|
||||
p1.Run.rPr.Name := '宋体';
|
||||
p1.Run.rPr.Bold := true;
|
||||
p1.Run.rPr.Size := 32;
|
||||
@@ -481,7 +488,7 @@ Begin
|
||||
///添加页眉、页脚案例
|
||||
_AddTitle(docx, '添加页眉、页脚案例', 2);
|
||||
help := TOfficeObj('TParagraph');
|
||||
help.Run.T := '参考word_help.tsl脚本(TDocxFile::Sections, TDocSection::AddHeader, TDocSection::AddFooter)!';
|
||||
help.Run.SetText( '参考word_help.tsl脚本(TDocxFile::Sections, TDocSection::AddHeader, TDocSection::AddFooter)!' );
|
||||
help.Format.FirstLineIndent := 220; //指定段落第一行缩进的相对差异的值
|
||||
help.Format.LeftIndent := 440;//段落左边距
|
||||
help.Font.Name := '宋体';
|
||||
@@ -494,7 +501,7 @@ Begin
|
||||
footer := section.AddFooter('');//添加缺省页脚
|
||||
//页脚内容
|
||||
p := TOfficeObj('TParagraph');
|
||||
p.Run.T := '电 话:0755-83937039';
|
||||
p.Run.SetText( '电 话:0755-83937039' );
|
||||
p.AddRun('网 址:http://www.tinysoft.com.cn', true);
|
||||
p.AddRun('公司地址:深圳市福田区莲花街道梅岭社区新闻路59号深茂商业中心19F', true);
|
||||
p.Format.Bdr.Top.val := 'single';//页脚横线
|
||||
@@ -512,7 +519,7 @@ Begin
|
||||
//添加页眉
|
||||
header := section.AddHeader('');//添加缺省页眉
|
||||
p := TOfficeObj('TParagraph');
|
||||
p.Run.T := '深圳市天软科技开发有限公司';
|
||||
p.Run.SetText( '深圳市天软科技开发有限公司' );
|
||||
p.Format.Alignment := 'right'; //据右对齐
|
||||
//p.Format.Bdr.Bottom.val := 'single';//页眉横线
|
||||
p.Font.Name := '宋体';
|
||||
@@ -565,7 +572,7 @@ Begin
|
||||
p1 := TOfficeObj('TParagraph');
|
||||
p1.Format.FirstLineIndent := 220; //指定段落第一行缩进的相对差异的值
|
||||
p1.Format.LeftIndent := 440;//段落左边距
|
||||
p1.Run.T := '深圳市天软公司';
|
||||
p1.Run.SetText( '深圳市天软公司' );
|
||||
p1.Run.rPr.Name := '宋体';
|
||||
pTest := docx.AddParagraph(p1, -1, nil);
|
||||
//修改部分文字字体
|
||||
@@ -641,7 +648,7 @@ Begin
|
||||
p.Font.Color := 'FF0000';
|
||||
p.Font.Bold := true;
|
||||
p.Format.LeftIndent := 700;//段落左边距
|
||||
p.Run.T := 'NumberId("bullet", ' $ i $ ')';
|
||||
p.Run.SetText( 'NumberId("bullet", ' $ i $ ')' );
|
||||
docx.AddParagraph(p, -1, nil);
|
||||
End;
|
||||
|
||||
@@ -814,7 +821,7 @@ Begin
|
||||
if not ifString(conf[i]['comment']) or conf[i]['comment'] = '' then continue;
|
||||
arr := str2array(conf[i]['funcname'], '(');
|
||||
k := lowercase(arr[0]);
|
||||
if hash[k]=1 and ( not k in array('create')) then continue;
|
||||
if hash[k]=1 and not (k in array('create')) then continue;
|
||||
hash[k] := 1;
|
||||
subject := head $ ind++ $ ' ' $ conf[i]['funcname'];
|
||||
_AddTitle(docx, conf[i]['funcname'], level);
|
||||
@@ -825,7 +832,7 @@ Begin
|
||||
pFun.Format.LeftIndent := 1760;//段落左边距
|
||||
pFun.Font.Name := '宋体';
|
||||
println(' Subject:{}', subject);
|
||||
pFun.Run.T := 'Function ' + conf[i]['funcname'];
|
||||
pFun.Run.SetText( 'Function ' + conf[i]['funcname'] );
|
||||
p1 := docx.AddParagraph(pFun, -1, nil);//函数方法
|
||||
//设置首行字体颜色、黑体
|
||||
firstRun := p1.GetRun(0);
|
||||
@@ -836,7 +843,7 @@ Begin
|
||||
//添加函数帮助信息段落
|
||||
arr := str2array(conf[i]['comment'], '\n');
|
||||
for j:=0 to length(arr)-1 do Begin
|
||||
pFun.Run.T := '///' + arr[j];
|
||||
pFun.Run.SetText('///' + arr[j]);
|
||||
p2 := docx.AddParagraph(pFun, -1, nil);
|
||||
End;
|
||||
|
||||
@@ -1088,7 +1095,7 @@ Begin
|
||||
str := str[2:];
|
||||
println(' FAQ: {}', str);
|
||||
End;
|
||||
p.Run.T := str;
|
||||
p.Run.SetText( str );
|
||||
End;
|
||||
if title then Begin
|
||||
p.Format.numPr.Level := 0;//项目编号
|
||||
|
||||
Reference in New Issue
Block a user