Compare commits
16
Commits
word
..
4a2961a635
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a2961a635 | ||
|
|
9f660c09f6 | ||
|
|
1e9b8f3a12 | ||
|
|
b617f235fa | ||
|
|
ee7b7164ce | ||
|
|
aab0a498c6 | ||
|
|
5172a78e3e | ||
|
|
de0af521bc | ||
|
|
8cd87118d5 | ||
|
|
9c917cfb70 | ||
|
|
d72d88d68a | ||
|
|
5f1064794d | ||
|
|
493691b930 | ||
|
|
f3094c148c | ||
|
|
addc41144e | ||
|
|
8aa050461c |
@@ -1,28 +1,28 @@
|
||||
path := ExtractFileDir(ExtractFileDir(PluginPath()));
|
||||
{$IFNDEF Win32}
|
||||
path := path + '\\funcext\\TSOffice\\TSExcelFile.tsf';
|
||||
path := path + '\\funcext\\TSOffice\\TSXlsxFile.tsf';
|
||||
{$ELSE}
|
||||
path := path + '/funcext/TSOffice/TSExcelFile.tsf';
|
||||
path := path + '/funcext/TSOffice/TSXlsxFile.tsf';
|
||||
{$ENDIF}
|
||||
funcs := LoadClassInfo(path);
|
||||
|
||||
testing := 1;
|
||||
file := new TSExcelFile();
|
||||
file := new TSXlsxFile();
|
||||
[err, errinfo] := file.NewFile();
|
||||
if err then
|
||||
return PrintError("NewFile", err, errinfo);
|
||||
PrintSuccess("NewFile", testing++);
|
||||
|
||||
file.SetSheetName('Sheet1', 'ExcelFile');
|
||||
file.SetSheetName('Sheet1', 'XlsxFile');
|
||||
PrintSuccess("SetSheetName", testing++);
|
||||
|
||||
file.NewSheet("Functions");
|
||||
PrintSuccess("NewSheet", testing++);
|
||||
|
||||
file.SetDefaultSheet('ExcelFile');
|
||||
file.SetDefaultSheet('TSXlsxFile');
|
||||
|
||||
richtext := TOfficeObj('TRichText');
|
||||
txt1 := richtext.AddText('TSExcelFile类 ');
|
||||
txt1 := richtext.AddText('TSXlsxFile类 ');
|
||||
txt1.Font.Size := 35;
|
||||
txt1.Font.Color := "FF0000";
|
||||
txt1.Font.Bold := 1;
|
||||
@@ -34,14 +34,14 @@ txt2.Font.Bold := 1;
|
||||
txt2.Font.Italic := 1;
|
||||
txt2.Font.Color := "FFC0CB";
|
||||
|
||||
file.SetCellRichText('ExcelFile', 'A1', richtext);
|
||||
file.SetCellRichText('XlsxFile', 'A1', richtext);
|
||||
PrintSuccess("SetCellRichText", testing++);
|
||||
[err, richText] := file.GetCellRichText('ExcelFile', 'A1');
|
||||
[err, richText] := file.GetCellRichText('XlsxFile', 'A1');
|
||||
if err then
|
||||
return PrintError("GetCellRichText", err, errinfo);
|
||||
PrintSuccess("GetCellRichText", testing++);
|
||||
|
||||
file.MergeCell('ExcelFile', 'A1', 'C1');
|
||||
file.MergeCell('XlsxFile', 'A1', 'C1');
|
||||
PrintSuccess("MergeCell", testing++);
|
||||
|
||||
|
||||
@@ -65,15 +65,15 @@ style.Fill.Gradient.Stop2.Color := "E0EBF5";
|
||||
styleId := file.NewStyle(style);
|
||||
PrintSuccess("NewStyle", testing++);
|
||||
|
||||
file.SetCellStyle("ExcelFile", 'A1', 'C1', styleId);
|
||||
file.SetCellStyle("XlsxFile", 'A1', 'C1', styleId);
|
||||
|
||||
file.SetCellValue("ExcelFile", "A3", "索引");
|
||||
file.SetCellValue("ExcelFile", "B3", "函数名称");
|
||||
file.SetCellValue("ExcelFile", "C3", "功能");
|
||||
file.SetColWidth("ExcelFile", "A", "A", 6);
|
||||
file.SetColWidth("ExcelFile", "B", "B", 55);
|
||||
file.SetColWidth("ExcelFile", "C", "C", 100);
|
||||
file.SetCellStyle("ExcelFile", "A3", "C3", styleId);
|
||||
file.SetCellValue("XlsxFile", "A3", "索引");
|
||||
file.SetCellValue("XlsxFile", "B3", "函数名称");
|
||||
file.SetCellValue("XlsxFile", "C3", "功能");
|
||||
file.SetColWidth("XlsxFile", "A", "A", 6);
|
||||
file.SetColWidth("XlsxFile", "B", "B", 55);
|
||||
file.SetColWidth("XlsxFile", "C", "C", 100);
|
||||
file.SetCellStyle("XlsxFile", "A3", "C3", styleId);
|
||||
|
||||
|
||||
style2 := TOfficeObj("TStyle");
|
||||
@@ -108,9 +108,9 @@ Begin
|
||||
[err0, cell0] := file.CoordinatesToCellName(1, i+4);
|
||||
[err1, cell1] := file.CoordinatesToCellName(2, i+4);
|
||||
[err2, cell2] := file.CoordinatesToCellName(3, i+4);
|
||||
file.SetCellValue("ExcelFile", cell0, i+1);
|
||||
file.SetCellValue("ExcelFile", cell1, funcs[i]['funcname']);
|
||||
file.SetCellValue("ExcelFile", cell2, funcs[i]['name']);
|
||||
file.SetCellValue("XlsxFile", cell0, i+1);
|
||||
file.SetCellValue("XlsxFile", cell1, funcs[i]['funcname']);
|
||||
file.SetCellValue("XlsxFile", cell2, funcs[i]['name']);
|
||||
|
||||
str := funcs[i]['name'] + "\nFunction " + funcs[i]['funcname'] + funcs[i]['comment'];
|
||||
arr := str2array(str, "\n");
|
||||
@@ -130,15 +130,15 @@ Begin
|
||||
hyperlink.LinkType := "location";
|
||||
hyperlink.LinkUrl := "Functions!" $ c1;
|
||||
|
||||
file.SetCellHyperLink("ExcelFile", cell1, hyperlink);
|
||||
file.SetCellStyle("ExcelFile", cell1, cell1, styleId4);
|
||||
file.SetCellHyperLink("XlsxFile", cell1, hyperlink);
|
||||
file.SetCellStyle("XlsxFile", cell1, cell1, styleId4);
|
||||
|
||||
End
|
||||
|
||||
file.SetColWidth('Functions', 'A', 'A', 120);
|
||||
PrintSuccess('SetColWidth', testing++);
|
||||
|
||||
saveName := utf8toansi("ExcelFile使用帮助.xlsx");
|
||||
saveName := utf8toansi("XlsxFile使用帮助.xlsx");
|
||||
[err, errinfo] := file.SaveAs('', saveName);
|
||||
if err then
|
||||
return PrintError("SaveAs", err, errinfo);
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -12,17 +12,19 @@ TSOffice 项目:纯 TSL 代码实现 excel、word 文件读写
|
||||
|
||||
可选:
|
||||
|
||||
- `fmt_pubkrnl_plugin` 放入 tsl 安装根目录下 Plugin 文件夹,若需要执行Demo文件夹下的[ExcelHelp.tsl](./Demo/ExcelHelp.tsl)和[WordHelp.tsl](./Demo/WordHelp.tsl),需要部署改动态库
|
||||
- `fmt_pubkrnl_plugin` 放入 tsl 安装根目录下 Plugin 文件夹,若需要执行Demo文件夹下的[XlsxHelp.tsl](./Demo/XlsxHelp.tsl)和[DocxHelp.tsl](./Demo/DocxHelp.tsl),需要部署改动态库
|
||||
|
||||
### Linux
|
||||
|
||||
#### Ubuntu-18.04
|
||||
|
||||
根据架构选择aarch64或x86版本将对应文件夹内容进行部署
|
||||
|
||||
- `liboffice_plugin` 放入 tsl 安装根目录下 Plugin 文件夹
|
||||
|
||||
## 帮助文档
|
||||
|
||||
- [Excel 帮助文档](./ExcelFile使用帮助.xlsx)
|
||||
- [Excel 帮助文档](./XlsxFile使用帮助.xlsx)
|
||||
|
||||
- [Word 帮助文档](./DocxFile使用帮助.docx)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+1184
-979
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
// Version 1.4.4
|
||||
// Version 1.5.2
|
||||
|
||||
Type TSDocxFile = Class
|
||||
///Version: V1.0 2022-09-20
|
||||
@@ -124,6 +124,13 @@ Type TSDocxFile = Class
|
||||
return document_.Body().Paragraphs();
|
||||
End;
|
||||
|
||||
///word文档最后一个段落
|
||||
///返回:TParagraph对象
|
||||
Function LastParagraph();
|
||||
Begin
|
||||
return document_.Body().LastParagraph();
|
||||
End;
|
||||
|
||||
///添加新段落
|
||||
///paragraph: TParagraph对象
|
||||
///posOpt: 段落位置,0 在DOCX文件开头;-1 文件尾;N 在第N段之后;XmlNode节点对象或DocObject对象 在posOpt之后新添加段落
|
||||
@@ -230,10 +237,12 @@ Type TSDocxFile = Class
|
||||
///插入数据表
|
||||
///tbl: TTable对象
|
||||
///posOpt: 段落位置,0 在DOCX文件开头;-1 文件尾;N 在第N段之后;XmlNode节点对象或DocObject对象 在posOpt之后新添加表格
|
||||
///customCell: 二维数组,自定义指定单元格的样式
|
||||
/// 如:一行一列arr[0][0] := array(twtcPr, twpPr, twrPr);其中twtcPr是twtcPr对象,twpPr是twpPr对象,twrPr是twrPr对象
|
||||
///返回: TTable对象
|
||||
Function InsertTable(tbl, posOpt);
|
||||
Function InsertTable(tbl, posOpt, customCell);
|
||||
Begin
|
||||
return document_.Body().InsertTable(tbl, getPosNode(posOpt));
|
||||
return document_.Body().InsertTable(tbl, getPosNode(posOpt), customCell);
|
||||
End;
|
||||
|
||||
///返回CoreProperties对象
|
||||
@@ -372,6 +381,25 @@ Type TSDocxFile = Class
|
||||
return nil;
|
||||
End;
|
||||
|
||||
///复制Word内容
|
||||
///alias: string,文件目录别名
|
||||
///fileName: string,文件名
|
||||
///posOpt: 段落位置,0 在DOCX文件开头;-1 文件尾;N 在第N段之后;XmlNode节点对象或DocObject对象 在posOpt之后新添加图片
|
||||
///返回: [err, TDocxCopy对象]
|
||||
///TDocxCopy.GetCopiedTable() 返回复制的对象表格数组
|
||||
///TDocxCopy.GetCopiedParagraph() 返回复制对象的段落数组
|
||||
///TDocxCopy.GetCopiedDrawing() 返回复制对象的图表数组
|
||||
Function InsertFile(alias, fileName, posOpt);overload;
|
||||
Begin
|
||||
docxObj := new TSDocxFile();
|
||||
[err, msg] := docxObj.OpenFile(alias, fileName);
|
||||
if err then return array(err, msg);
|
||||
copy_obj := new TDocxCopy(self, docxObj);
|
||||
copy_obj.Init();
|
||||
copy_obj.Copy(posOpt);
|
||||
return array(0, copy_obj);
|
||||
End;
|
||||
|
||||
///复制Word内容
|
||||
///docxObj: TSDocxFile对象
|
||||
///posOpt: 段落位置,0 在DOCX文件开头;-1 文件尾;N 在第N段之后;XmlNode节点对象或DocObject对象 在posOpt之后新添加图片
|
||||
@@ -379,11 +407,8 @@ Type TSDocxFile = Class
|
||||
///TDocxCopy.GetCopiedTable() 返回复制的对象表格数组
|
||||
///TDocxCopy.GetCopiedParagraph() 返回复制对象的段落数组
|
||||
///TDocxCopy.GetCopiedDrawing() 返回复制对象的图表数组
|
||||
Function InsertFile(alias, fileName, posOpt);
|
||||
Function InsertFile(docxObj, posOpt);overload;
|
||||
Begin
|
||||
docxObj := new TSDocxFile();
|
||||
[err, msg] := docxObj.OpenFile(alias, fileName);
|
||||
if err then return array(err, msg);
|
||||
copy_obj := new TDocxCopy(self, docxObj);
|
||||
copy_obj.Init();
|
||||
copy_obj.Copy(posOpt);
|
||||
@@ -510,7 +535,7 @@ Type TSDocxFile = Class
|
||||
///返回:array((("Level":level,"Paragraph":"object","Text":title));
|
||||
Function GetHeadingList(UpperHeadingLevel, LowerHeadingLevel);
|
||||
Begin
|
||||
return document_.Body().GetHeadingListImpl(self, nil, UpperHeadingLevel, LowerHeadingLevel, nil, true);
|
||||
return document_.Body().GetHeadingListImpl(self, nil, UpperHeadingLevel, LowerHeadingLevel, nil);
|
||||
End;
|
||||
|
||||
//返回Document对象
|
||||
@@ -535,6 +560,17 @@ Type TSDocxFile = Class
|
||||
return numberingObj_;
|
||||
End;
|
||||
|
||||
///返回:TFootnotes对象
|
||||
Function FootNotesObject();
|
||||
Begin
|
||||
if not ifObj(footnotesObj_) then
|
||||
begin
|
||||
footnotesObj_ := new TOfficeObj('TFootnoteBody');
|
||||
footnotesObj_.InitFootnotes(self.Zip());
|
||||
end
|
||||
return footnotesObj_;
|
||||
End;
|
||||
|
||||
///执行word文档内嵌tsl代码(执行内嵌脚本的环境字符集为GBK)
|
||||
///返回:[err,tslFuncCount,errArr]: err 执行错误TSL代码段次数,tslFuncCount TSL代码段总数,errArr 执行TSL错误信息(array(('code':'代码', 'err':'错误信息')))
|
||||
Function ExecInnerTSL();
|
||||
@@ -591,6 +627,7 @@ private
|
||||
zipfile_; //压缩文件对象
|
||||
document_; //Document对象
|
||||
styleObj_;
|
||||
footnotesObj_;
|
||||
numberingObj_;
|
||||
DocPrId_;
|
||||
End;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Version 1.4.4
|
||||
// Version 1.5.0
|
||||
|
||||
Type TSExcelFile = Class
|
||||
///Version: V1.0 2022-08-08
|
||||
@@ -915,7 +915,7 @@ Type TSExcelFile = Class
|
||||
|
||||
///复制Sheet
|
||||
///sourceSheet: 源工作表
|
||||
///destSheet: 目的工作表
|
||||
///destSheet: 目的工作表,如果destSheet存在,则覆盖destSheet,否则末尾新增destSheet
|
||||
Function CopySheet(sourceSheet, destSheet);
|
||||
Begin
|
||||
return workbook_.CopySheet(class(TSXml).CurCodePageToUtf8(sourceSheet), class(TSXml).CurCodePageToUtf8(destSheet));
|
||||
|
||||
@@ -18,25 +18,31 @@ public
|
||||
return RootObj;
|
||||
End
|
||||
|
||||
Function Update();
|
||||
Function Update(position);overload;
|
||||
Begin
|
||||
if ifObj(RootObj) then Begin
|
||||
arr := Marshal();
|
||||
if length(arr['attributes']) or length(arr['children']) then Begin
|
||||
curNode := class(TSXml).GetNode(RootObj, NodeUri);
|
||||
curNode := class(TSXml).GetNode(RootObj, NodeUri, position);
|
||||
if ifObj(curNode) then
|
||||
class(TSXml).UpdateNode(curNode, arr['attributes'], arr['children']);
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
Function HandleAttrs(); virtual;
|
||||
Function Update();overload;
|
||||
Begin
|
||||
End
|
||||
self.Update("end");
|
||||
End;
|
||||
|
||||
Function HandleChildren(); virtual;
|
||||
Function Delete();
|
||||
Begin
|
||||
End
|
||||
if ifObj(RootObj) then
|
||||
begin
|
||||
curNode := class(TSXml).GetNode(RootObj, NodeUri);
|
||||
if ifObj(curNode) then curNode.DeleteChildren();
|
||||
end
|
||||
End;
|
||||
|
||||
Function GetAttrs(); virtual;
|
||||
Begin
|
||||
@@ -71,27 +77,16 @@ public
|
||||
children_ := nil;
|
||||
GetChildrenEx(); //优化为变量,减少数据COPY,2022-12-10
|
||||
child_arr := array();
|
||||
name_map := array();
|
||||
len := 0;
|
||||
for i:=0 to length(children_)-1 do
|
||||
begin
|
||||
node_type := children_[i]['nodeType'];
|
||||
obj := children_[i]['obj'];
|
||||
if ifnil(obj) then continue;
|
||||
//find := select thisrowindex as "rowindex_", * from child_arr where ['name'] = children_[i]['name'] end; //优化为循环,性能提高15-20%,2022-12-20
|
||||
find := array();
|
||||
for j:=length(child_arr)-1 downto 0 do Begin //支持列表模式(如多节点:<w:t xml:space=""></w:t>),查找最近的节点
|
||||
if child_arr[j]['name'] = children_[i]['name'] then Begin
|
||||
find[0] := child_arr[j];
|
||||
find[0]['rowindex_'] := j;
|
||||
break;
|
||||
End;
|
||||
End;
|
||||
if not ifnil(obj) and not ifObj(obj) and istable(find) and ifstring(children_[i]['attrEx']) and children_[i]['attrEx'] <> '' then
|
||||
if not ifObj(obj) and not ifnil(name_map[children_[i]['name']]) and children_[i]['attrEx'] <> '' then
|
||||
begin
|
||||
if not ifarray(find[0]['attributes']) then find[0]['attributes'] := array();
|
||||
key := children_[i]['attrEx'];
|
||||
find[0]['attributes'] union= array(key : obj);
|
||||
child_arr[find[0]['rowindex_']]['attributes'] := find[0]['attributes'];
|
||||
child_arr[name_map[children_[i]['name']]]['attributes'] union=array(children_[i]['attrEx'] : obj);
|
||||
continue;
|
||||
end
|
||||
|
||||
@@ -118,7 +113,7 @@ public
|
||||
key := children_[i]['attrName'] ? children_[i]['attrName'] : children_[i]['attrEx'] ? children_[i]['attrEx'] : 'val';
|
||||
arr['attributes'] := array(key : obj);
|
||||
end
|
||||
|
||||
name_map[children_[i]['name']] := len;
|
||||
child_arr[len++] := arr;
|
||||
end
|
||||
|
||||
@@ -154,7 +149,7 @@ public
|
||||
return 1;
|
||||
End
|
||||
|
||||
Function Value(name);
|
||||
Function Value(name, nottransferable);
|
||||
Begin
|
||||
if not ifObj(RootObj) then return nil;
|
||||
if NodeUri <> '' then
|
||||
@@ -169,7 +164,7 @@ public
|
||||
if istable(r) then
|
||||
begin
|
||||
value := node.GetAttribute(r[1]);
|
||||
return trystrtofloat(value, r) ? r : value;
|
||||
return nottransferable ? value : trystrtofloat(value, r) ? r : value;
|
||||
end
|
||||
|
||||
children := GetChildren();
|
||||
@@ -186,7 +181,7 @@ public
|
||||
key := r['attrName'] ? r['attrName'] : r['attrEx'] ? r['attrEx'] : 'val';
|
||||
value := node.GetAttribute(key);
|
||||
if r['nodeType'] = 'empty' and value = '' then return true;
|
||||
return trystrtofloat(value, r) ? r : value;
|
||||
return nottransferable ? value : trystrtofloat(value, r) ? r : value;
|
||||
End;
|
||||
return nil;
|
||||
End;
|
||||
@@ -269,7 +264,6 @@ public
|
||||
NodeName;
|
||||
ExtAttr;
|
||||
ExtNodes;
|
||||
//Parent;
|
||||
ReplaceArr;
|
||||
RootObj; // xml node
|
||||
NodeUri:string;
|
||||
|
||||
@@ -71,12 +71,14 @@ Type TSImage = Class
|
||||
Begin
|
||||
des1 := 0xff;
|
||||
des2 := 0xc0;
|
||||
des3 := 0xc2;
|
||||
flag := 1;
|
||||
while flag do
|
||||
begin
|
||||
stringObj_.Read(byte1, 1);
|
||||
stringObj_.Read(byte2, 1);
|
||||
if byte1 = des1 and byte2 = des2 then flag := 0;
|
||||
r1 := stringObj_.Read(byte1, 1);
|
||||
r2 := stringObj_.Read(byte2, 1);
|
||||
if r1 = 0 or r2 = 0 then break;
|
||||
if byte1 = des1 and (byte2 = des2 or byte2 = des3) then flag := 0;
|
||||
end
|
||||
if flag then return array(0, 0);
|
||||
stringObj_.Read(tmp, 3);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ Type TDocxCopy = class
|
||||
copy_drawing_ := array();
|
||||
style_copy_obj_ := new TDocxStyleCopy(oldObj.StyleObject(), newObj.StyleObject());
|
||||
number_copy_obj_ := new TDocxNumberCopy(oldObj, newObj);
|
||||
footnote_copy_obj_ := new TDocxFootnoteCopy(oldObj, newObj);
|
||||
End;
|
||||
|
||||
Function Init();
|
||||
@@ -21,7 +22,7 @@ Type TDocxCopy = class
|
||||
Function Copy(posOpt);
|
||||
Begin
|
||||
// 复制所有的样式
|
||||
style_copy_obj_.CopyStyle();
|
||||
style_copy_obj_.CopyStyle(number_copy_obj_);
|
||||
|
||||
parts := new_docx_obj_.Body().Parts();
|
||||
pos := old_docx_obj_.GetPosNode(posOpt);
|
||||
@@ -110,6 +111,7 @@ private
|
||||
|
||||
// 比较新文件的图片在旧文件中是否存在
|
||||
zip := old_docx_obj_.Zip();
|
||||
xml := zip.Get('word/_rels/document.xml.rels');
|
||||
files := sselect ['FileName'] from zip.Files() where AnsiStartsText('word/media/image', ['FileName']) end;
|
||||
for i:=0 to length(files)-1 do Begin
|
||||
if zip.Diff(files[i], image_file) = 0 then Begin
|
||||
@@ -117,7 +119,6 @@ private
|
||||
[maxRid, imageFile, rid] := class(TSXml).FindRelationshipRid(xml, prefix);
|
||||
End;
|
||||
End;
|
||||
xml := zip.Get('word/_rels/document.xml.rels');
|
||||
if rid = 0 then
|
||||
begin
|
||||
image_cnt := length(files) + 1;
|
||||
@@ -131,9 +132,9 @@ private
|
||||
zip.Add('word/' + image_path, image_file);
|
||||
contentXml := zip.Get('[Content_Types].xml');
|
||||
class(TSXml).AddDefaultContentType(contentXml, postfix, 'image/' $ postfix);
|
||||
end
|
||||
end
|
||||
node.SetAttribute('r:embed', 'rId' $ rid);
|
||||
end
|
||||
end
|
||||
End;
|
||||
|
||||
Function SetChart(node);
|
||||
@@ -210,21 +211,64 @@ private
|
||||
|
||||
Function SetParagraphInfo(paragraph);
|
||||
Begin
|
||||
style := class(TSXml).GetNode(paragraph.node_, 'w:pPr/w:pStyle');
|
||||
CopyStyle(paragraph.node_, 'w:pPr/w:pStyle');
|
||||
CopyNumber(paragraph.node_, 'w:pPr/w:numPr/w:numId');
|
||||
SetRunsInfo(paragraph.node_);
|
||||
DeleteComment(paragraph); // 删除批注
|
||||
End;
|
||||
|
||||
Function SetRunsInfo(node);
|
||||
Begin
|
||||
run := node.FirstChildElement('w:r');
|
||||
while ifObj(run) do
|
||||
begin
|
||||
CopyFootnote(run);
|
||||
CopyStyle(run, 'w:rPr/w:rStyle');
|
||||
run := run.NextElement();
|
||||
end
|
||||
End;
|
||||
|
||||
Function CopyStyle(node, path);
|
||||
Begin
|
||||
style := class(TSXml).GetNode(node, path);
|
||||
if ifObj(style) then
|
||||
begin
|
||||
styleid := style.GetAttribute('w:val');
|
||||
new_id := style_copy_obj_.GetStyleNewId(styleid);
|
||||
if new_id then style.SetAttribute('w:val', new_id);
|
||||
end
|
||||
numpr := class(TSXml).GetNode(paragraph.node_, 'w:pPr/w:numPr/w:numId');
|
||||
End;
|
||||
|
||||
Function CopyNumber(node, path);
|
||||
Begin
|
||||
numpr := class(TSXml).GetNode(node, path);
|
||||
if ifObj(numpr) then
|
||||
begin
|
||||
id := numpr.GetAttribute('w:val');
|
||||
numberid := number_copy_obj_.CopyNumbering(id);
|
||||
numpr.SetAttribute('w:val', id);
|
||||
numpr.SetAttribute('w:val', numberid);
|
||||
end
|
||||
End;
|
||||
|
||||
Function CopyFootnote(node);
|
||||
Begin
|
||||
footnote := node.FirstChildElement('w:footnoteReference');
|
||||
if not ifObj(footnote) then return;
|
||||
id := footnote.GetAttribute('w:id');
|
||||
if id then
|
||||
begin
|
||||
obj := footnote_copy_obj_.CopyFootnote(id);
|
||||
footnote.SetAttribute('w:id', obj.Id);
|
||||
parts := obj.Parts();
|
||||
for i:=0 to length(parts)-1 do
|
||||
begin
|
||||
case GetPartType(parts[i]) of
|
||||
0: SetParagraphInfo(parts[i]);
|
||||
1: SetDrawingInfo(parts[i]);
|
||||
2: SetTableInfo(parts[i]);
|
||||
end;
|
||||
end
|
||||
end
|
||||
DeleteComment(paragraph); // 删除批注
|
||||
End;
|
||||
|
||||
Function SetTableInfo(table);
|
||||
@@ -295,6 +339,7 @@ private
|
||||
new_docx_obj_;
|
||||
style_copy_obj_;
|
||||
number_copy_obj_;
|
||||
footnote_copy_obj_;
|
||||
|
||||
copy_table_;
|
||||
copy_paragraph_;
|
||||
@@ -326,11 +371,12 @@ Type TDocxStyleCopy = class
|
||||
end
|
||||
End;
|
||||
|
||||
Function CopyStyle();
|
||||
Function CopyStyle(numberobj);
|
||||
Begin
|
||||
for id, obj in id_map_ do
|
||||
begin
|
||||
SetBasedOn(obj);
|
||||
SetNumId(obj, numberobj);
|
||||
SetLink(obj);
|
||||
old_style_obj_.CopyStyle(obj);
|
||||
end;
|
||||
@@ -382,11 +428,23 @@ private
|
||||
end
|
||||
End;
|
||||
|
||||
Function SetNumId(obj, numberobj);
|
||||
Begin
|
||||
if not ifObj(numberobj) then return;
|
||||
numPr := class(TSXml).GetNode(obj.node_, 'w:pPr/w:numPr/w:numId');
|
||||
if ifObj(numPr) then
|
||||
begin
|
||||
id := numpr.GetAttribute('w:val');
|
||||
numberid := numberobj.CopyNumbering(id);
|
||||
numpr.SetAttribute('w:val', numberid);
|
||||
end
|
||||
End;
|
||||
|
||||
Function GetNewName(name);
|
||||
Begin
|
||||
new_name := name;
|
||||
count := 0;
|
||||
while ifObj(old_style_obj_.GetStyle(new_name)) or style_name_map2_[new_name] do
|
||||
while ifObj(old_style_obj_.GetStyle(class(TSXml).Utf8ToCurCodePage(new_name))) or style_name_map2_[new_name] do
|
||||
new_name := new_name $ count++;
|
||||
return new_name;
|
||||
End;
|
||||
@@ -437,9 +495,9 @@ Type TDocxNumberCopy = class
|
||||
begin
|
||||
number_obj := old_number_obj_.CopyNumber(obj);
|
||||
id_map_[number] := number_obj;
|
||||
return number_obj;
|
||||
end
|
||||
end;
|
||||
return id_map_[number];
|
||||
end
|
||||
End;
|
||||
|
||||
private
|
||||
@@ -448,3 +506,40 @@ private
|
||||
|
||||
id_map_; // [id: styleobj]
|
||||
End;
|
||||
|
||||
Type TDocxFootnoteCopy = class
|
||||
|
||||
Function Create(oldObj, newObj);
|
||||
Begin
|
||||
footnotexml := newObj.Zip().Get('word/footnotes.xml');
|
||||
if ifObj(footnotexml) then
|
||||
begin
|
||||
old_footnote_obj_ := oldObj.FootNotesObject();
|
||||
new_footnote_obj_ := newObj.FootNotesObject();
|
||||
end
|
||||
else begin
|
||||
old_footnote_obj_ := nil;
|
||||
new_footnote_obj_ := nil;
|
||||
end
|
||||
id_map_ := array();
|
||||
End;
|
||||
|
||||
Function CopyFootnote(id);
|
||||
Begin
|
||||
if ifObj(old_footnote_obj_) and ifObj(new_footnote_obj_) then
|
||||
begin
|
||||
if (obj := new_footnote_obj_.GetFootnote(id)) and not id_map_[id] then
|
||||
begin
|
||||
footnote_obj := old_footnote_obj_.CopyFootnote(obj);
|
||||
id_map_[id] := footnote_obj;
|
||||
end
|
||||
return id_map_[id];
|
||||
end
|
||||
End;
|
||||
|
||||
private
|
||||
old_footnote_obj_;
|
||||
new_footnote_obj_;
|
||||
|
||||
id_map_; // [id: footnote]
|
||||
End;
|
||||
|
||||
@@ -142,7 +142,7 @@ Type TTableContent = class
|
||||
Begin
|
||||
///获取标题列表 array((("Level":level,"Paragraph":"object","Text":title,"numId":,"ilvl":,"numArr":));
|
||||
numMap := array();
|
||||
r := docx_.Document().Body().GetHeadingListImpl(docx_, posOpt, UpperHeadingLevel, LowerHeadingLevel, numMap, true);
|
||||
r := docx_.Document().Body().GetHeadingListImpl(docx_, nil, UpperHeadingLevel, LowerHeadingLevel, numMap);
|
||||
for i:=0 to length(r)-1 do Begin
|
||||
p := _AddItem(UpperHeadingLevel, LowerHeadingLevel, r[i]['Level'], i = 0 ? true: false);
|
||||
//fldCharType
|
||||
@@ -160,9 +160,9 @@ Type TTableContent = class
|
||||
if ifObj(style) then
|
||||
numStr := style.GetText(r[i]['ilvl'], r[i]['numArr']);
|
||||
End
|
||||
if numStr <> '' then run_t := numStr + ' ' + r[i]['Text'];
|
||||
else run_t := r[i]['Text'];
|
||||
r1.SetText(run_t);
|
||||
run_t := class(TSXml).CurCodePageToUtf8(r[i]['Text']);
|
||||
if numStr <> '' then run_t := numStr + ' ' + run_t;
|
||||
r1.SetText(run_t, 1);
|
||||
|
||||
r2 := h.AddRun();
|
||||
r2.rPr.noProof := true;
|
||||
@@ -203,7 +203,6 @@ Type TTableContent = class
|
||||
r8.fldCharType := 'end';
|
||||
|
||||
_AddStdContent(p);
|
||||
|
||||
End;
|
||||
|
||||
p2 := TOfficeObj('TParagraph');
|
||||
@@ -221,6 +220,26 @@ Type TTableContent = class
|
||||
Begin
|
||||
End;
|
||||
|
||||
Function Paragraphs();
|
||||
Begin
|
||||
node := class(TSXml).GetNode(docx_.Document().Body().Node(), 'w:sdt/w:sdtContent');
|
||||
r := array();
|
||||
if ifObj(node) then
|
||||
begin
|
||||
twbody := TOfficeObj('TwBody');
|
||||
twbody.Create(nil, 'w:sdtContent');
|
||||
twbody.InitRootNode(node);
|
||||
twbody.InitNode(node);
|
||||
parts := twbody.Paragraphs();
|
||||
for i:=0 to length(parts)-1 do
|
||||
begin
|
||||
r[i] := TOfficeObj('TParagraph');
|
||||
r[i].Init(parts[i].node_);
|
||||
end
|
||||
end
|
||||
return r;
|
||||
End;
|
||||
|
||||
Function Marshal();
|
||||
Begin
|
||||
return impl_.Marshal();
|
||||
@@ -299,3 +318,4 @@ Type TTableContent = class
|
||||
node_;
|
||||
impl_;
|
||||
End;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ Type docxDocument = Class
|
||||
bodyNode_ := root_.FirstChildElement('w:body');
|
||||
body_ := TOfficeObj('TwBody');
|
||||
body_.InitNode(bodyNode_);
|
||||
body_.InitRootNode(bodyNode_);
|
||||
body_.zipfile_ := z;
|
||||
body_.document_ := self;
|
||||
bookmarkid_ := -1;
|
||||
@@ -29,7 +30,7 @@ Type docxDocument = Class
|
||||
markStart := p.FirstChildElement('w:bookmarkStart');
|
||||
if ifObj(markStart) then Begin
|
||||
id := markStart.GetAttribute('w:id');
|
||||
if ifstring(id) then Begin
|
||||
if ifstring(id) and id <> '' then Begin
|
||||
iVal := strtoint(id);
|
||||
if bookmarkid_ <= iVal then
|
||||
bookmarkid_ := iVal + 1;
|
||||
|
||||
@@ -166,64 +166,71 @@ Type xlsxWorkBook = Class
|
||||
Begin
|
||||
lname := LowerCase(sheet);
|
||||
if ifint(sheetIndexMap_[ lname ]) then return 'The sheet already exists.';
|
||||
rid := getWorkbookRelsRid();
|
||||
|
||||
fname := sheetPrefix_ $ inttostr(sheetsCount_ + 1) $ '.xml';
|
||||
sheetId := addSheetN(fname);
|
||||
rid := setWorkbookRels();
|
||||
setWorkbookSheet(sheet, sheetId, rid);
|
||||
setDocPropsApp(sheet);
|
||||
setContentTypes(fname);
|
||||
|
||||
sheetNames_[sheetsCount_]['name'] := sheet;
|
||||
sheetNames_[sheetsCount_]['sheetId'] := sheetId;
|
||||
sheetNames_[sheetsCount_]['rid'] := rid;
|
||||
sheetNames_[sheetsCount_]['file'] := fname;
|
||||
sheetIndexMap_[ lname ] := sheetsCount_;
|
||||
sheetsCount_ ++;
|
||||
SetDefaultSheet(sheet);
|
||||
End;
|
||||
|
||||
Function addSheetN(fname);
|
||||
Begin
|
||||
//添加文件xl/worksheets/sheetN.xml
|
||||
sheetId := vselect maxof(['sheetId']) from sheetNames_ end;
|
||||
sheetId := integer(sheetId) + 1;
|
||||
fname := sheetPrefix_ $ inttostr(sheetsCount_ + 1) $ '.xml';
|
||||
zipfile_.Add(fname, class(TSXml).XmlHeader() + class(TSXml).GetTemplate('sheet1'));
|
||||
return sheetId;
|
||||
End;
|
||||
|
||||
Function setWorkbookRels();
|
||||
Begin
|
||||
rid := getWorkbookRelsRid();
|
||||
//设置 workbook.xml.rels
|
||||
workbook_rels := GetXmlFileObj('xl/_rels/workbook.xml.rels');
|
||||
rels := workbook_rels.FirstChildElement('Relationships').InsertEndChild('element', 'Relationship');
|
||||
rels.SetAttribute('Target', getTarget( sheetsCount_ + 1));
|
||||
rels.SetAttribute('Type', class(TSXml).GetTemplate('RelationshipWorkSheet'));
|
||||
rels.SetAttribute('Id', rid);
|
||||
//workbook_rels.Print;
|
||||
return rid;
|
||||
End;
|
||||
|
||||
Function setWorkbookSheet(sheetName, sheetId, rid);
|
||||
Begin
|
||||
//设置 xl/workbook.xml
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
node := workbook.FirstChildElement('workbook').FirstChildElement('sheets').InsertEndChild('element','sheet');
|
||||
node.SetAttribute('name', sheet);
|
||||
node.SetAttribute('name', sheetName);
|
||||
node.SetAttribute('sheetId', sheetId);
|
||||
node.SetAttribute('r:id', rid);
|
||||
//workbook.Print();
|
||||
End;
|
||||
|
||||
Function setDocPropsApp(sheet);
|
||||
Begin
|
||||
//设置docProps/app.xml
|
||||
app := GetXmlFileObj(class(TSXml).GetFileName('docProps_app'));
|
||||
//app.Print();
|
||||
node := app.FirstChildElement('Properties').FirstChildElement('TitlesOfParts');
|
||||
if not ifObj(node) then Begin
|
||||
node := app.FirstChildElement('Properties').InsertEndChild('element','TitlesOfParts');
|
||||
End;
|
||||
vector := node.FirstChildElement('vt:vector');
|
||||
if not ifObj(vector) then Begin
|
||||
vector := node.InsertEndChild('element', 'vt:vector');
|
||||
vector.SetAttribute('baseType', 'lpstr');
|
||||
vector.SetAttribute('size', length(sheetNames_) + 1);
|
||||
for i:=0 to length(sheetNames_)-1 do Begin
|
||||
vector.InsertEndChild('element', 'vt:lpstr', sheetNames_[i]['name']);
|
||||
End;
|
||||
End
|
||||
else
|
||||
vector := class(TSXml).GetNode(app, 'Properties/TitlesOfParts/vt:vector');
|
||||
vector.SetAttribute('size', length(sheetNames_) + 1);
|
||||
vector.InsertEndChild('element', 'vt:lpstr', sheet);
|
||||
//app.Print();
|
||||
End;
|
||||
|
||||
Function setContentTypes(fname);
|
||||
Begin
|
||||
//设置[Content_Types].xml
|
||||
content_xml := GetXmlFileObj(class(TSXml).GetFileName('Content_Types'));
|
||||
class(TSXml).AddOverrideContentType(content_xml, '/' + fname, class(TSXml).GetTemplate('sheetContentType'));
|
||||
|
||||
sheetNames_[sheetsCount_]['name'] := sheet;
|
||||
sheetNames_[sheetsCount_]['sheetId'] := sheetId;
|
||||
sheetNames_[sheetsCount_]['rid'] := rid;
|
||||
sheetNames_[sheetsCount_]['file'] := fname;
|
||||
sheetIndexMap_[ LowerCase(sheet) ] := sheetsCount_;
|
||||
sheetsCount_ ++;
|
||||
SetDefaultSheet(sheet);
|
||||
End;
|
||||
|
||||
|
||||
Function NewSheet(sourceSheet, destSheet);overload;
|
||||
Begin
|
||||
lname := LowerCase(destSheet);
|
||||
@@ -512,15 +519,19 @@ Type xlsxWorkBook = Class
|
||||
|
||||
Function CopySheet(sourceSheet, destSheet);
|
||||
Begin
|
||||
ind := sheetIndexMap_[ LowerCase(destSheet) ];
|
||||
if ifint(ind) then return destSheet $ ' already exists.';
|
||||
ind := sheetIndexMap_[ LowerCase(sourceSheet) ];
|
||||
if not ifint(ind) then return sourceSheet $ ' does not exists.';
|
||||
dest_ind := sheetIndexMap_[ LowerCase(destSheet) ];
|
||||
|
||||
//copy sheet
|
||||
sheetId := vselect maxof(['sheetId']) from sheetNames_ end;
|
||||
sheetId := integer(sheetId) + 1;
|
||||
if ifint(dest_ind) then
|
||||
begin
|
||||
fname := sheetNames_[dest_ind]['file'];
|
||||
zipfile_.Remove(fname);
|
||||
end
|
||||
else begin
|
||||
fname := sheetPrefix_ $ inttostr(sheetsCount_ + 1) $ '.xml';
|
||||
end
|
||||
sheet := GetSheetXmlFile(sourceSheet);
|
||||
zipfile_.Add(fname, sheet.Data());
|
||||
xml_file := GetXmlFileObj(fname);
|
||||
@@ -549,7 +560,14 @@ Type xlsxWorkBook = Class
|
||||
sheet_rels := GetSheetRelsFile(sourceSheet);
|
||||
if ifObj(sheet_rels) then
|
||||
begin
|
||||
if ifint(dest_ind) then
|
||||
begin
|
||||
rels_name := 'xl/worksheets/_rels/' + ExtractFileName(sheetNames_[dest_ind]['file']) + '.rels';
|
||||
zipfile_.Remove(rels_name);
|
||||
end
|
||||
else begin
|
||||
rels_name := 'xl/worksheets/_rels/' + 'sheet' + inttostr(sheetsCount_ + 1) + '.xml.rels';
|
||||
end
|
||||
zipfile_.Add(rels_name, sheet_rels.Data());
|
||||
rels_file := GetXmlFileObj(rels_name);
|
||||
relationship := rels_file.FirstChildElement('Relationships').FirstChildElement('Relationship');
|
||||
@@ -576,6 +594,8 @@ Type xlsxWorkBook = Class
|
||||
end
|
||||
end
|
||||
|
||||
if ifint(dest_ind) then return;
|
||||
|
||||
//workbook.xml.rels
|
||||
rid := getWorkbookRelsRid();
|
||||
workbook_rels := GetXmlFileObj('xl/_rels/workbook.xml.rels');
|
||||
@@ -585,6 +605,8 @@ Type xlsxWorkBook = Class
|
||||
rels.SetAttribute('Id', rid);
|
||||
|
||||
//xl/workbook.xml
|
||||
sheetId := vselect maxof(['sheetId']) from sheetNames_ end;
|
||||
sheetId := integer(sheetId) + 1;
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
node := workbook.FirstChildElement('workbook').FirstChildElement('sheets').InsertEndChild('element','sheet');
|
||||
node.SetAttribute('name', destSheet);
|
||||
@@ -726,23 +748,25 @@ Type xlsxWorkBook = Class
|
||||
Function SetSheetVisible(sheet, visible);
|
||||
Begin
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
node := workbook.FirstChildElement('workbook').FirstChildElement('sheets').FirstChildElement('sheet');
|
||||
hidden := visible = 1 ? 0 : 1;
|
||||
default_sheet_name := GetDefaultSheet();
|
||||
if default_sheet_name = sheet then
|
||||
node := class(TSXml).GetNode(workbook, 'workbook/sheets/sheet');
|
||||
if GetSheetsCount() = 1 then return "Only one sheet, can't set visible.";
|
||||
sheet := lowercase(sheet);
|
||||
default_sheet_name := lowercase(GetDefaultSheet());
|
||||
if default_sheet_name = sheet and not visible then
|
||||
begin
|
||||
ind := sheetIndexMap_[LowerCase(default_sheet_name)];
|
||||
if ind = 0 then default_name := sheetNames_[ind + 1]['name'];
|
||||
else default_name := sheetNames_[ind - 1]['name'];
|
||||
default_name := ind = 0 ? sheetNames_[1]['name'] : sheetNames_[ind - 1]['name'];
|
||||
SetDefaultSheet(default_name);
|
||||
end
|
||||
if visible then SetDefaultSheet(sheet);
|
||||
state := visible ? "nohidden" : "hidden";
|
||||
while ifObj(node) do
|
||||
Begin
|
||||
name := node.GetAttribute('name');
|
||||
name := lowercase(node.GetAttribute('name'));
|
||||
if name = sheet then
|
||||
Begin
|
||||
if hidden then node.SetAttribute('state', 'hidden');
|
||||
else node.DeleteAttribute('state');
|
||||
node.SetAttribute('state', state);
|
||||
break;
|
||||
End
|
||||
node := node.NextElement();
|
||||
End
|
||||
@@ -753,11 +777,12 @@ Type xlsxWorkBook = Class
|
||||
Begin
|
||||
sheet_file := GetSheetXmlFile(sheet);
|
||||
if not ifObj(sheet_file) then return 0;
|
||||
sheet := lowercase(sheet);
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
node := workbook.FirstChildElement('workbook').FirstChildElement('sheets').FirstChildElement('sheet');
|
||||
node := class(TSXml).GetNode(workbook, 'workbook/sheets/sheet');
|
||||
while ifObj(node) do
|
||||
Begin
|
||||
name := node.GetAttribute('name');
|
||||
name := lowercase(node.GetAttribute('name'));
|
||||
if name = sheet then
|
||||
Begin
|
||||
val := node.GetAttribute('state');
|
||||
@@ -1104,29 +1129,17 @@ Type xlsxWorkBook = Class
|
||||
node := sheet_node.InsertFirstChild('element', 'sheetView');
|
||||
node.SetAttribute('workbookViewId', 0);
|
||||
end
|
||||
if name = sheet then
|
||||
if lowercase(name) = lowercase(sheet) then
|
||||
Begin
|
||||
node.SetAttribute('tabselected', 1);
|
||||
node.SetAttribute('tabSelected', 1);
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
workbook_node := workbook.FirstChildElement('workbook');
|
||||
book_view_node := workbook_node.FirstChildElement('bookViews');
|
||||
if not ifObj(book_view_node) then
|
||||
begin
|
||||
prev_node := class(TSXml).GetWorkBookPrevNode(workbook_node, 'bookViews');
|
||||
if not ifObj(prev_node) then book_view_node := workbook_node.InsertFirstChild('element', 'bookViews');
|
||||
else book_view_node := workbook_node.InsertAfterChild(prev_node, 'element', 'bookViews');
|
||||
end;
|
||||
view_node := book_view_node.FirstChildElement('workbookView');
|
||||
if not ifObj(view_node) then
|
||||
begin
|
||||
view_node := book_view_node.InsertFirstChild('element', 'workbookView');
|
||||
end
|
||||
view_node := class(TSXml).GetNode(workbook, 'workbook/bookViews/workbookView');
|
||||
view_node.SetAttribute('activeTab', ind);
|
||||
End
|
||||
else
|
||||
begin
|
||||
node := root_node.FirstChildElement('sheetViews').FirstChildElement('sheetView');
|
||||
node.SetAttribute('tabselected', 0);
|
||||
node.SetAttribute('tabSelected', 0);
|
||||
end
|
||||
end
|
||||
End
|
||||
|
||||
@@ -1,5 +1,92 @@
|
||||
# 更新日志
|
||||
|
||||
## 2023-12-1
|
||||
|
||||
### V1.5.2
|
||||
|
||||
#### excel
|
||||
|
||||
1. 修复公式中文转码问题
|
||||
|
||||
## 2023-11-15
|
||||
|
||||
### V1.5.1
|
||||
|
||||
1. 支持识别图片中含有`0xffc2`段的jpg格式的大小
|
||||
|
||||
## 2023-11-14
|
||||
|
||||
### V1.5.0
|
||||
|
||||
#### word
|
||||
|
||||
1. 新增对脚注的支持,方法`TSDocxFile.FootnotesObject().Add`
|
||||
2. `TSDocxFile.InsertFile`支持脚注插入
|
||||
|
||||
### excel
|
||||
|
||||
1. 升级`TSXlsxFile.CopySheet`
|
||||
|
||||
## 2023-10-16
|
||||
|
||||
### V1.4.9
|
||||
|
||||
#### word
|
||||
|
||||
1. 新增`TSDocxFile.InsertFile`重载方法
|
||||
2. 新增`Table.SetStyle`方法
|
||||
|
||||
## 2023-9-27
|
||||
|
||||
### V1.4.8
|
||||
|
||||
#### word
|
||||
|
||||
1. 支持`Inserttable`时候加入对单元格样式的设置
|
||||
2. 新增`TSDocxFile.LastParagraph`方法
|
||||
3. 新增`TParagraph.PrevParagraph`方法
|
||||
4. 性能优化
|
||||
|
||||
## 2023-9-22
|
||||
|
||||
### V1.4.7
|
||||
|
||||
#### word
|
||||
|
||||
1. 修复项目符号属于样式时,生成目录无法识别出项目符号问题
|
||||
|
||||
## 2023-9-19
|
||||
|
||||
### V1.4.6
|
||||
|
||||
#### word
|
||||
|
||||
1. 修复表格存在合并单元格,生成目录报错问题
|
||||
2. 修复单元格添加 run 对象,设置样式不生效问题
|
||||
3. 修复插入 word 后,中文样式重复问题
|
||||
|
||||
### excel
|
||||
|
||||
🔔 重要升级:`TSExcelFile`更名为`TSXlsxFile`,建议更改,旧名字现阶段仍可使用
|
||||
|
||||
1. 整理`NewSheet`和`SetSheetVisible`代码
|
||||
|
||||
#### excel
|
||||
|
||||
1. 修复`NewSheet`excel 打开遇到提示错误问题
|
||||
|
||||
## 2023-8-30
|
||||
|
||||
### V1.4.5
|
||||
|
||||
#### word
|
||||
|
||||
1. 支持生成目录后返回目录对象的所有段落内容`目录对象.Paragraphs()`
|
||||
|
||||
#### excel
|
||||
|
||||
1. 修复`NewSheet`excel 打开遇到提示错误问题
|
||||
|
||||
## 2023-8-28
|
||||
|
||||
### V1.4.4
|
||||
@@ -8,7 +95,7 @@
|
||||
|
||||
1. 修复`insertFile`样式错误问题
|
||||
2. 修复`insertFile`后删除段落再新增段落位置错误问题
|
||||
3. 修复生成目录中文编码未转换导致word打开失败问题
|
||||
3. 修复生成目录中文编码未转换导致 word 打开失败问题
|
||||
|
||||
## 2023-8-22
|
||||
|
||||
@@ -24,7 +111,7 @@
|
||||
|
||||
#### word
|
||||
|
||||
支持插入另一个word内容`InsertFile(alias, fileName, posOpt)`
|
||||
支持插入另一个 word 内容`InsertFile(alias, fileName, posOpt)`
|
||||
|
||||
## 2023-8-11
|
||||
|
||||
@@ -32,7 +119,7 @@
|
||||
|
||||
#### word
|
||||
|
||||
修复插入表格后,设置样式ID无法全部生效问题
|
||||
修复插入表格后,设置样式 ID 无法全部生效问题
|
||||
|
||||
## 2023-8-10
|
||||
|
||||
@@ -40,7 +127,7 @@
|
||||
|
||||
#### word
|
||||
|
||||
支持三级以内目录设置字体,一级目录样式ID为`TOC1`,二级目录样式ID为`TOC2`,三级为`TOC3`,通过样式设置相关属性即可修改目录字体
|
||||
支持三级以内目录设置字体,一级目录样式 ID 为`TOC1`,二级目录样式 ID 为`TOC2`,三级为`TOC3`,通过样式设置相关属性即可修改目录字体
|
||||
|
||||
## 2023-8-7
|
||||
|
||||
@@ -48,7 +135,7 @@
|
||||
|
||||
#### word
|
||||
|
||||
支持`AddHeading`时传入样式Id
|
||||
支持`AddHeading`时传入样式 Id
|
||||
|
||||
## 2023-8-2
|
||||
|
||||
@@ -80,13 +167,13 @@
|
||||
|
||||
#### word
|
||||
|
||||
段落字体大小设置调整,对齐VBA设置
|
||||
段落字体大小设置调整,对齐 VBA 设置
|
||||
|
||||
## 2023-7-11
|
||||
|
||||
### V1.3.4
|
||||
|
||||
修复加密Bug
|
||||
修复加密 Bug
|
||||
|
||||
## 2023-7-4
|
||||
|
||||
@@ -98,11 +185,11 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
### V1.3.2
|
||||
|
||||
修复.net使用rdo2执行失败问题,使用rdo2时候,需调用`TOfficeInit()`初始化
|
||||
修复.net 使用 rdo2 执行失败问题,使用 rdo2 时候,需调用`TOfficeInit()`初始化
|
||||
|
||||
#### word
|
||||
|
||||
1. 修复word模板`template.docx`执行失败问题
|
||||
1. 修复 word 模板`template.docx`执行失败问题
|
||||
|
||||
## 2023-6-20
|
||||
|
||||
@@ -122,7 +209,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### excel
|
||||
|
||||
1. 支持excel程序设置字体样式粗体,斜体等此类问题的返回类型,如`style.Font.Bold`返回`true 或 false`
|
||||
1. 支持 excel 程序设置字体样式粗体,斜体等此类问题的返回类型,如`style.Font.Bold`返回`true 或 false`
|
||||
|
||||
## 2023-4-4
|
||||
|
||||
@@ -138,7 +225,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### excel
|
||||
|
||||
1. 修复由.net客户端导出的excel兼容性问题,`SetColWidth`、`Set/GetDefaultSheet`、`SetSheetHeaderFooter`
|
||||
1. 修复由.net 客户端导出的 excel 兼容性问题,`SetColWidth`、`Set/GetDefaultSheet`、`SetSheetHeaderFooter`
|
||||
|
||||
## 2023-3-23
|
||||
|
||||
@@ -207,7 +294,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### excel
|
||||
|
||||
1. Get相关方法重新Set后不再覆盖原有设置,影响方法如下`Set(Get)PageMargins`,`Set(Get)CellHyperLink`,`Set(Get)PageLayout`,`Set(Get)CalcOptions`,`Set(Get)DefaultFont`,`Set(Get)SheetViewOptions`
|
||||
1. Get 相关方法重新 Set 后不再覆盖原有设置,影响方法如下`Set(Get)PageMargins`,`Set(Get)CellHyperLink`,`Set(Get)PageLayout`,`Set(Get)CalcOptions`,`Set(Get)DefaultFont`,`Set(Get)SheetViewOptions`
|
||||
|
||||
## 2023-2-23
|
||||
|
||||
@@ -244,7 +331,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
1. 新增`LoadFromMem`, `SavaToMem`
|
||||
2. 新增重载方法`NewSheet`
|
||||
3. 新增`SetCalcOptions`
|
||||
4. 修复删除sheet报错问题
|
||||
4. 修复删除 sheet 报错问题
|
||||
|
||||
## 2023-2-13
|
||||
|
||||
@@ -280,7 +367,7 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### word
|
||||
|
||||
1. 修复获取段落样式ID失败问题
|
||||
1. 修复获取段落样式 ID 失败问题
|
||||
2. 修复文本框添加图片失败问题
|
||||
|
||||
#### excel
|
||||
@@ -337,8 +424,8 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### word
|
||||
|
||||
1. 新增ExecInnerTSl
|
||||
2. 新增修改chart图(数据)
|
||||
1. 新增 ExecInnerTSl
|
||||
2. 新增修改 chart 图(数据)
|
||||
3. 修复`TNumbering::AddStyleByInnerXml`错误
|
||||
4. 完善帮助文档
|
||||
|
||||
@@ -356,11 +443,11 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### word
|
||||
|
||||
1. 修复chart图兼容性问题
|
||||
1. 修复 chart 图兼容性问题
|
||||
|
||||
### V1.0.6
|
||||
|
||||
中文自动转换API由`class(xlsxXml).CodePage('中文');`调整为`TOfficeApi().CodePage('中文');`
|
||||
中文自动转换 API 由`class(xlsxXml).CodePage('中文');`调整为`TOfficeApi().CodePage('中文');`
|
||||
|
||||
## 2023-1-5
|
||||
|
||||
@@ -370,15 +457,15 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
|
||||
#### word
|
||||
|
||||
1. 修复 Properties执行报错
|
||||
1. 修复 Properties 执行报错
|
||||
2. 修复格式刷
|
||||
|
||||
#### excel
|
||||
|
||||
1. 移除API `JoinCellName`
|
||||
1. 移除 API `JoinCellName`
|
||||
2. 修改`RGBToHSL`与`HSLToRGB`返回值
|
||||
3. 修复获取超链接`GetCellHyperLink`失败问题
|
||||
4. 修复一个对象新建文件,打开文件之后引发的xlsx文件错误问题
|
||||
4. 修复一个对象新建文件,打开文件之后引发的 xlsx 文件错误问题
|
||||
5. 修复`GetCoreProps`,`GetAppProps`失败问题
|
||||
|
||||
## 2022-12-30
|
||||
@@ -398,4 +485,4 @@ word/excel 新增加密方法`SetPassword`,升级`OpenFile(alias, fileName, Pa
|
||||
5. 修复`SetRowVisible`,`GetRowVisible`,`SetSheetVisible`问题
|
||||
|
||||
如何设置字符集(中文支持)?
|
||||
★用户的脚本可能是UFT8格式,或可能是GBK码格式,系统提供API自动设置当前字符集环境:`class(xlsxXml).CodePage('中文');` 在文件头设置该代码后,系统会自动检测当前的环境字符集
|
||||
★ 用户的脚本可能是 UFT8 格式,或可能是 GBK 码格式,系统提供 API 自动设置当前字符集环境:`class(xlsxXml).CodePage('中文');` 在文件头设置该代码后,系统会自动检测当前的环境字符集
|
||||
|
||||
Reference in New Issue
Block a user