v1.0.4
This commit is contained in:
+292
-127
@@ -1,3 +1,4 @@
|
||||
// Version 1.0.4
|
||||
Function TOfficeObj(n);
|
||||
Begin
|
||||
case lowercase(n) of
|
||||
@@ -199,8 +200,8 @@ Begin
|
||||
return new TwInline();
|
||||
"twdrawing":
|
||||
return new TwDrawing();
|
||||
"tinstrtext":
|
||||
return new TInstrText();
|
||||
"ttext":
|
||||
return new TText();
|
||||
"trun":
|
||||
return new TRun();
|
||||
"tbookmark":
|
||||
@@ -333,52 +334,59 @@ type TFont=class(NodeInfo)
|
||||
Function GetChildren(); override;
|
||||
Begin
|
||||
HandleChildren();
|
||||
return array(("field":"Background","name":"background","obj":Background,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Bold","name":"b","obj":Bold,"attrEx":"","nodeType":"empty","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Color","name":"color","obj":Color,"attrEx":"","nodeType":"","attrName":"rgb", "desc":"", "class":"")
|
||||
,("field":"ColorIndex","name":"color","obj":ColorIndex,"attrEx":"index","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"FontStyle","name":"fontstyle","obj":FontStyle,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Italic","name":"i","obj":Italic,"attrEx":"","nodeType":"empty","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Name","name":"name","obj":Name,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"OutlineFont","name":"outlinefont","obj":OutlineFont,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Shadow","name":"shadow","obj":Shadow,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
return array(("field":"FontName","name":"name","obj":FontName,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Size","name":"sz","obj":Size,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Strikethrough","name":"strike","obj":Strikethrough,"attrEx":"","nodeType":"empty","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Subscript","name":"subscript","obj":Subscript,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Superscript","name":"superscript","obj":Superscript,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Underline","name":"u","obj":Underline,"attrEx":"","nodeType":"empty_string","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Bold","name":"b","obj":Bold,"attrEx":"","nodeType":"empty","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Italic","name":"i","obj":Italic,"attrEx":"","nodeType":"empty","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Color","name":"color","obj":Color,"attrEx":"","nodeType":"","attrName":"rgb", "desc":"", "class":"")
|
||||
,("field":"ThemeColor","name":"color","obj":ThemeColor,"attrEx":"theme","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"TintAndShade","name":"tintandshade","obj":TintAndShade,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"ThemeFont","name":"scheme","obj":ThemeFont,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Strikethrough","name":"strike","obj":Strikethrough,"attrEx":"","nodeType":"empty","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Script","name":"vertAlign","obj":Script,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Charset","name":"charset","obj":Charset,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Underline","name":"u","obj":Underline,"attrEx":"","nodeType":"empty_string","attrName":"", "desc":"", "class":"")
|
||||
,("field":"FontStyle","name":"fontstyle","obj":FontStyle,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"OutlineFont","name":"outlinefont","obj":OutlineFont,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Shadow","name":"shadow","obj":Shadow,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"TintAndShade","name":"tintandshade","obj":TintAndShade,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Background","name":"background","obj":Background,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"rFont","name":"rFont","obj":rFont,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"ThemeFont","name":"scheme","obj":ThemeFont,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"ColorIndex","name":"color","obj":ColorIndex,"attrEx":"index","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Subscript","name":"subscript","obj":Subscript,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Superscript","name":"superscript","obj":Superscript,"attrEx":"","nodeType":"","attrName":"", "desc":"", "class":"")
|
||||
) union ExtNodes;
|
||||
End;
|
||||
|
||||
Property Name write writeName;
|
||||
Function writeName(n);
|
||||
Begin
|
||||
nName := class(xlsxXml).CurCodePageToUtf8(n);
|
||||
FontName := nName;
|
||||
End;
|
||||
|
||||
//Attributes
|
||||
|
||||
//Nodes
|
||||
Background;
|
||||
Bold;
|
||||
Color;
|
||||
ColorIndex;
|
||||
FontStyle;
|
||||
Italic;
|
||||
Name;
|
||||
OutlineFont;
|
||||
Shadow;
|
||||
FontName;
|
||||
Size;
|
||||
Strikethrough;
|
||||
Subscript;
|
||||
Superscript;
|
||||
Underline;
|
||||
Bold;
|
||||
Italic;
|
||||
Color;
|
||||
ThemeColor;
|
||||
TintAndShade;
|
||||
ThemeFont;
|
||||
Strikethrough;
|
||||
Script;
|
||||
Charset;
|
||||
Underline;
|
||||
FontStyle;
|
||||
OutlineFont;
|
||||
Shadow;
|
||||
TintAndShade;
|
||||
Background;
|
||||
rFont;
|
||||
ThemeFont;
|
||||
ColorIndex;
|
||||
Subscript;
|
||||
Superscript;
|
||||
End;
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -3660,7 +3668,7 @@ type THyperLink=class(NodeInfo)
|
||||
Function GetAttrs(); override;
|
||||
Begin
|
||||
HandleAttrs();
|
||||
return array(("LinkType", "linkType", LinkType, ""),("LinkUrl", "linkUrl", LinkUrl, ""),("Axis", "ref", Axis, ""),("Display", "display", Display, ""),("Tooltip", "tooltip", Tooltip, "")) union ExtAttr;
|
||||
return array(("LinkType", "linkType", LinkType, ""),("Url", "linkUrl", Url, ""),("Axis", "ref", Axis, ""),("LinkDisplay", "display", LinkDisplay, ""),("LinkTooltip", "tooltip", LinkTooltip, "")) union ExtAttr;
|
||||
End;
|
||||
|
||||
Function GetChildren(); override;
|
||||
@@ -3669,12 +3677,30 @@ type THyperLink=class(NodeInfo)
|
||||
return ExtNodes;
|
||||
End;
|
||||
|
||||
Property LinkUrl read Url write writeUrl;
|
||||
Function writeUrl(str);
|
||||
Begin
|
||||
Url := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Display read LinkDisplay write writeLinkDisplay;
|
||||
Function writeLinkDisplay(str);
|
||||
Begin
|
||||
LinkDisplay := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Tooltip read LinkTooltip write writeLinkTooltip;
|
||||
Function writeLinkTooltip(str);
|
||||
Begin
|
||||
LinkTooltip := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
//Attributes
|
||||
LinkType;
|
||||
LinkUrl;
|
||||
Url;
|
||||
Axis;
|
||||
Display;
|
||||
Tooltip;
|
||||
LinkDisplay;
|
||||
LinkTooltip;
|
||||
|
||||
//Nodes
|
||||
End;
|
||||
@@ -3798,30 +3824,54 @@ type TAppProperty=class(NodeInfo)
|
||||
Function GetChildren(); override;
|
||||
Begin
|
||||
HandleChildren();
|
||||
return array(("field":"Application","name":"Application","obj":Application,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
return array(("field":"AppApplication","name":"Application","obj":AppApplication,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"DocSecurity","name":"DocSecurity","obj":DocSecurity,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"ScaleCrop","name":"ScaleCrop","obj":ScaleCrop,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Manager","name":"Manager","obj":Manager,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Company","name":"Company","obj":Company,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"AppManager","name":"Manager","obj":AppManager,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"AppCompany","name":"Company","obj":AppCompany,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"LinksUpToDate","name":"LinksUpToDate","obj":LinksUpToDate,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"SharedDoc","name":"SharedDoc","obj":SharedDoc,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"HyperlinkBase","name":"HyperlinkBase","obj":HyperlinkBase,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"AppHyperlinkBase","name":"HyperlinkBase","obj":AppHyperlinkBase,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"HyperlinksChanged","name":"HyperlinksChanged","obj":HyperlinksChanged,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"AppVersion","name":"AppVersion","obj":AppVersion,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
) union ExtNodes;
|
||||
End;
|
||||
|
||||
Property Application read AppApplication write writeAppApplication;
|
||||
Function writeAppApplication(str);
|
||||
Begin
|
||||
AppApplication := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Manager read AppManager write writeAppManager;
|
||||
Function writeAppManager(str);
|
||||
Begin
|
||||
AppManager := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Company read AppCompany write writeAppCompany;
|
||||
Function writeAppCompany(str);
|
||||
Begin
|
||||
AppCompany := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property HyperlinkBase read AppHyperlinkBase write writeAppHyperlinkBase;
|
||||
Function writeAppHyperlinkBase(str);
|
||||
Begin
|
||||
AppHyperlinkBase := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
//Attributes
|
||||
|
||||
//Nodes
|
||||
Application;
|
||||
AppApplication;
|
||||
DocSecurity;
|
||||
ScaleCrop;
|
||||
Manager;
|
||||
Company;
|
||||
AppManager;
|
||||
AppCompany;
|
||||
LinksUpToDate;
|
||||
SharedDoc;
|
||||
HyperlinkBase;
|
||||
AppHyperlinkBase;
|
||||
HyperlinksChanged;
|
||||
AppVersion;
|
||||
End;
|
||||
@@ -3855,30 +3905,84 @@ type TCoreProperty=class(NodeInfo)
|
||||
Function GetChildren(); override;
|
||||
Begin
|
||||
HandleChildren();
|
||||
return array(("field":"Title","name":"dc:title","obj":Title,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Subject","name":"dc:subject","obj":Subject,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Creator","name":"dc:creator","obj":Creator,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Keywords","name":"cp:keywords","obj":Keywords,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Description","name":"dc:description","obj":Description,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"LastModifiedBy","name":"cp:lastModifiedBy","obj":LastModifiedBy,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"LastPrinted","name":"cp:lastPrinted","obj":LastPrinted,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"Category","name":"cp:category","obj":Category,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"ContentStatus","name":"cp:contentStatus","obj":ContentStatus,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
return array(("field":"CoreTitle","name":"dc:title","obj":CoreTitle,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreSubject","name":"dc:subject","obj":CoreSubject,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreCreator","name":"dc:creator","obj":CoreCreator,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreKeywords","name":"cp:keywords","obj":CoreKeywords,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreDescription","name":"dc:description","obj":CoreDescription,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreLastModifiedBy","name":"cp:lastModifiedBy","obj":CoreLastModifiedBy,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreLastPrinted","name":"cp:lastPrinted","obj":CoreLastPrinted,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreCategory","name":"cp:category","obj":CoreCategory,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
,("field":"CoreContentStatus","name":"cp:contentStatus","obj":CoreContentStatus,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
) union ExtNodes;
|
||||
End;
|
||||
|
||||
Property Title read CoreTitle write writeCoreTitle;
|
||||
Function writeCoreTitle(str);
|
||||
Begin
|
||||
CoreTitle := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Subject read CoreSubject write writeCoreSubject;
|
||||
Function writeCoreSubject(str);
|
||||
Begin
|
||||
CoreSubject := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Creator read CoreCreator write writeCoreCreator;
|
||||
Function writeCoreCreator(str);
|
||||
Begin
|
||||
CoreCreator := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Keywords read CoreKeywords write writeCoreKeywords;
|
||||
Function writeCoreKeywords(str);
|
||||
Begin
|
||||
CoreKeywords := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Description read CoreDescription write writeCoreDescription;
|
||||
Function writeCoreDescription(str);
|
||||
Begin
|
||||
CoreDescription := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property LastModifiedBy read CoreLastModifiedBy write writeCoreLastModifiedBy;
|
||||
Function writeCoreLastModifiedBy(str);
|
||||
Begin
|
||||
CoreLastModifiedBy := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property LastPrinted read CoreLastPrinted write writeCoreLastPrinted;
|
||||
Function writeCoreLastPrinted(str);
|
||||
Begin
|
||||
CoreLastPrinted := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property Category read CoreCategory write writeCoreCategory;
|
||||
Function writeCoreCategory(str);
|
||||
Begin
|
||||
CoreCategory := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
Property ContentStatus read CoreContentStatus write writeCoreContentStatus;
|
||||
Function writeCoreContentStatus(str);
|
||||
Begin
|
||||
CoreContentStatus := class(xlsxXml).CurCodePageToUtf8(str);
|
||||
End;
|
||||
|
||||
//Attributes
|
||||
|
||||
//Nodes
|
||||
Title;
|
||||
Subject;
|
||||
Creator;
|
||||
Keywords;
|
||||
Description;
|
||||
LastModifiedBy;
|
||||
LastPrinted;
|
||||
Category;
|
||||
ContentStatus;
|
||||
CoreTitle;
|
||||
CoreSubject;
|
||||
CoreCreator;
|
||||
CoreKeywords;
|
||||
CoreDescription;
|
||||
CoreLastModifiedBy;
|
||||
CoreLastPrinted;
|
||||
CoreCategory;
|
||||
CoreContentStatus;
|
||||
End;
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -4019,10 +4123,13 @@ type TwrPr=class(NodeInfo)
|
||||
Property Name write writeName;
|
||||
Function writeName(n);
|
||||
Begin
|
||||
rFont.cs := n;
|
||||
rFont.eastAsia := n;
|
||||
rFont.hAnsi := n;
|
||||
rFont.ascii := n;
|
||||
nName := n;
|
||||
if not class(xlsxXml).IsUtf8() then
|
||||
nName := class(xlsxXml).CurCodePageToUtf8(n);
|
||||
rFont.cs := nName;
|
||||
rFont.eastAsia := nName;
|
||||
rFont.hAnsi := nName;
|
||||
rFont.ascii := nName;
|
||||
End;
|
||||
|
||||
//Attributes
|
||||
@@ -5073,12 +5180,12 @@ type TwDrawing=class(NodeInfo)
|
||||
End;
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
/// TInstrText
|
||||
/// TText
|
||||
///////////////////////////////////////////////////////////////
|
||||
type TInstrText=class(NodeInfo)
|
||||
type TText=class(NodeInfo)
|
||||
Function Create(); overload;
|
||||
Begin
|
||||
Create(nil, 'w:instrText');
|
||||
Create(nil, 'w:t');
|
||||
End;
|
||||
|
||||
Function Create(p, name); overload;
|
||||
@@ -5101,7 +5208,7 @@ type TInstrText=class(NodeInfo)
|
||||
Function GetChildren(); override;
|
||||
Begin
|
||||
HandleChildren();
|
||||
return array(("field":"Data","name":"Data","obj":Data,"attrEx":"","nodeType":"pcdata","attrName":"", "desc":"", "class":"")
|
||||
return array(("field":"Text","name":"Text","obj":Text,"attrEx":"","nodeType":"tcdata","attrName":"", "desc":"", "class":"")
|
||||
) union ExtNodes;
|
||||
End;
|
||||
|
||||
@@ -5109,7 +5216,7 @@ type TInstrText=class(NodeInfo)
|
||||
Space;
|
||||
|
||||
//Nodes
|
||||
Data;
|
||||
Text;
|
||||
End;
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
@@ -7463,7 +7570,7 @@ type TTableStyle=class(NodeInfo)
|
||||
Function GetAttrs(); override;
|
||||
Begin
|
||||
HandleAttrs();
|
||||
return array(("TableName", "tableName", TableName, ""),("TableStyle", "name", TableStyle, ""),("ShowFirstColumn", "showFirstColumn", ShowFirstColumn, ""),("ShowLastColumn", "showLastColumn", ShowLastColumn, ""),("ShowRowStripes", "showRowStripes", ShowRowStripes, ""),("ShowColumnStripes", "showColumnStripes", ShowColumnStripes, ""),("HeaderRowCount", "HeaderRowCount", HeaderRowCount, ""),("TotalsRowShown", "totalsRowShown", TotalsRowShown, "")) union ExtAttr;
|
||||
return array(("Name", "tableName", Name, ""),("TableStyle", "name", TableStyle, ""),("ShowFirstColumn", "showFirstColumn", ShowFirstColumn, ""),("ShowLastColumn", "showLastColumn", ShowLastColumn, ""),("ShowRowStripes", "showRowStripes", ShowRowStripes, ""),("ShowColumnStripes", "showColumnStripes", ShowColumnStripes, ""),("HeaderRowCount", "HeaderRowCount", HeaderRowCount, ""),("TotalsRowShown", "totalsRowShown", TotalsRowShown, "")) union ExtAttr;
|
||||
End;
|
||||
|
||||
Function GetChildren(); override;
|
||||
@@ -7472,8 +7579,14 @@ type TTableStyle=class(NodeInfo)
|
||||
return ExtNodes;
|
||||
End;
|
||||
|
||||
Property TableName read Name write writeName;
|
||||
Function writeName(n);
|
||||
Begin
|
||||
Name := class(xlsxXml).CurCodePageToUtf8(n);
|
||||
End;
|
||||
|
||||
//Attributes
|
||||
TableName;
|
||||
Name;
|
||||
TableStyle;
|
||||
ShowFirstColumn;
|
||||
ShowLastColumn;
|
||||
@@ -7655,6 +7768,13 @@ Type DocObject = Class
|
||||
Begin
|
||||
obj.NodeName := 'w:ins';
|
||||
obj.name_ := obj.NodeName;
|
||||
tmpAuthor := obj.Author;
|
||||
tmpTxt := obj.InsText;
|
||||
if not class(xlsxXml).IsUtf8() then Begin
|
||||
if ifstring(obj.Author) then
|
||||
obj.Author := class(xlsxXml).CurCodePageToUtf8(obj.Author);
|
||||
obj.InsText := class(xlsxXml).CurCodePageToUtf8(obj.InsText);
|
||||
End;
|
||||
r := _split_range(obj.sPos, 0);
|
||||
if length(r) then Begin
|
||||
rNode := r[length(r)-1]['rNode'];
|
||||
@@ -7676,7 +7796,9 @@ Type DocObject = Class
|
||||
node2 := node.InsertEndChild('element', 'w:r');
|
||||
End;
|
||||
run := new TRun(node2);
|
||||
run.SetText(obj.InsText);
|
||||
run.SetText(obj.InsText, true);
|
||||
obj.InsText := tmpTxt;
|
||||
obj.Author := tmpAuthor;
|
||||
obj.Init(node);
|
||||
return true;
|
||||
End;
|
||||
@@ -7686,6 +7808,9 @@ Type DocObject = Class
|
||||
///返回:成功 true,失败 false
|
||||
Function DelRevision(obj);
|
||||
Begin
|
||||
tmpAuthor := obj.Author;
|
||||
if ifstring(obj.Author) and not class(xlsxXml).IsUtf8() then
|
||||
obj.Author := class(xlsxXml).CurCodePageToUtf8(obj.Author);
|
||||
r := _split_range(obj.sPos, obj.SelectLength);
|
||||
for i:=0 to length(r)-1 do Begin
|
||||
rNode := r[i]['rNode'];
|
||||
@@ -7695,6 +7820,7 @@ Type DocObject = Class
|
||||
delNode.InsertFirstChild(rXml);
|
||||
rNode.Parent().DeleteChild(rNode);
|
||||
End;
|
||||
obj.Author := tmpAuthor;
|
||||
return length(r);
|
||||
End;
|
||||
|
||||
@@ -7804,7 +7930,9 @@ Type DocObject = Class
|
||||
rSize := 0;
|
||||
for i:=0 to length(r)-1 do Begin
|
||||
run := new TRun(r[i]['rNode']);
|
||||
txt := UTF8ToAnsi(run.Text());
|
||||
txt := run.Text();
|
||||
if class(xlsxXml).IsUtf8() then
|
||||
txt := UTF8ToAnsi(txt);
|
||||
txtLen := lengthW(txt);
|
||||
if rangeLength >= 0 and sPos + rangeLength <= rSize then Begin
|
||||
return t;
|
||||
@@ -8242,8 +8370,8 @@ Type TParagraph = Class(DocObject, TParagraphImpl)
|
||||
o := new TRun();
|
||||
o.Parent := self;
|
||||
NewChildNode( array("field":"", "name":"w:r", "obj":o, "attrEx":"", "nodeType":"") );
|
||||
if ifString(txt) then
|
||||
o.T := txt;
|
||||
if txt then
|
||||
o.SetText(txt);
|
||||
if newLine then
|
||||
o.Br.Type := '';
|
||||
return o;
|
||||
@@ -8492,26 +8620,52 @@ Type TRun = Class(DocObject, TRunImpl)
|
||||
End;
|
||||
|
||||
///添加文字
|
||||
Function AddText(txt);
|
||||
///[isUtf8]:可选参数,当前字符集是否utf8,缺省false
|
||||
Function AddText(txt, isUtf8);
|
||||
Begin
|
||||
str := txt;
|
||||
if not isUtf8 and not class(xlsxXml).IsUtf8() then
|
||||
str := class(xlsxXml).CurCodePageToUtf8(txt);
|
||||
if ifObj(node_) then Begin
|
||||
_insertText(txt, false);
|
||||
_insertText(str, false);
|
||||
return;
|
||||
End;
|
||||
lines := str2array(txt,'\n');
|
||||
for i:=0 to length(lines)-1 do Begin
|
||||
//line := TrimRight(lines[i]);
|
||||
if i then
|
||||
NewChildNode( array("field":"", "name":"w:br", "obj":1, "attrEx":"", "nodeType":"empty") );
|
||||
lines := str2array(str,'\n');
|
||||
T := lines[0];
|
||||
if _preserve(T) then
|
||||
Space := 'preserve';
|
||||
for i:=1 to length(lines)-1 do Begin
|
||||
NewChildNode( array("field":"", "name":"w:br", "obj":1, "attrEx":"", "nodeType":"empty") );
|
||||
NewChildNode( array("field":"", "name":"w:t", "obj":lines[i], "attrEx":"", "nodeType":"pcdata") );
|
||||
if _preserve(lines[i]) then
|
||||
NewChildNode( array("field":"", "name":"w:t", "obj":'preserve', "attrEx":"xml:space", "nodeType":"") );
|
||||
End;
|
||||
End;
|
||||
|
||||
///修改文字
|
||||
Function SetText(txt);
|
||||
///[isUtf8]:可选参数,当前字符集是否utf8,缺省false
|
||||
Function SetText(txt, isUtf8);
|
||||
Begin
|
||||
ClearText();//删除原来文字
|
||||
_insertText(txt, false);//添加文字
|
||||
str := txt;
|
||||
if not isUtf8 and not class(xlsxXml).IsUtf8() then
|
||||
str := class(xlsxXml).CurCodePageToUtf8(txt);
|
||||
if ifObj(node_) then Begin
|
||||
ClearText();//删除原来文字
|
||||
_insertText(str, false);//添加文字
|
||||
return;
|
||||
End;
|
||||
ExtNodes := array();
|
||||
T := nil;
|
||||
AddText(str, true);
|
||||
End;
|
||||
|
||||
Function _preserve(str);
|
||||
Begin
|
||||
cnt := length(str);
|
||||
spaceArr := array(' ',' ');
|
||||
if cnt and (str[1] in spaceArr or (cnt > 1 and str[cnt] in spaceArr)) then
|
||||
return true;
|
||||
return false;
|
||||
End;
|
||||
|
||||
Function _insertText(txt, first);
|
||||
@@ -8545,6 +8699,8 @@ Type TRun = Class(DocObject, TRunImpl)
|
||||
// txt += '\n';
|
||||
tNode := tNode.NextElement();
|
||||
End;
|
||||
if not class(xlsxXml).IsUtf8() then
|
||||
return class(xlsxXml).Utf8ToCurCodePage(txt);
|
||||
return txt;
|
||||
End;
|
||||
|
||||
@@ -8559,11 +8715,13 @@ Type TRun = Class(DocObject, TRunImpl)
|
||||
///清除全部文字内容
|
||||
Function ClearText();
|
||||
Begin
|
||||
n := node_.FirstChildElement('w:t');
|
||||
while ifObj(n) do Begin
|
||||
next := n.NextElement('w:t');
|
||||
node_.DeleteChild(n);
|
||||
n := next;
|
||||
if ifObj(node_) then Begin
|
||||
n := node_.FirstChildElement('w:t');
|
||||
while ifObj(n) do Begin
|
||||
next := n.NextElement('w:t');
|
||||
node_.DeleteChild(n);
|
||||
n := next;
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
@@ -8732,7 +8890,22 @@ Type TChart = Class(TChartImpl)
|
||||
///添加图表Series数据
|
||||
Function AddSeries(Name, Categories, Value);
|
||||
Begin
|
||||
Series union= array(("Name":Name,"Categories":Categories,"Values":Value));
|
||||
SerName := name;
|
||||
catArr := Categories;
|
||||
if not class(xlsxXml).IsUtf8() then Begin
|
||||
if name and ifstring(name) then
|
||||
SerName := class(xlsxXml).CurCodePageToUtf8(name);
|
||||
if ifstring(catArr) then
|
||||
catArr := class(xlsxXml).CurCodePageToUtf8(catArr);
|
||||
else if istable(catArr) then Begin
|
||||
for i:=0 to length(catArr)-1 do Begin
|
||||
if ifstring(catArr[i]) then
|
||||
catArr[i] := class(xlsxXml).CurCodePageToUtf8(catArr[i]);
|
||||
End;
|
||||
End;
|
||||
End;
|
||||
|
||||
Series union= array(("Name":SerName,"Categories":catArr,"Values":Value));
|
||||
return length(Series);
|
||||
End;
|
||||
|
||||
@@ -9996,7 +10169,7 @@ Type TDocumentBody = Class(DocObject)
|
||||
Function AddHeading(title, posOpt, styleId);
|
||||
Begin
|
||||
paragraph := new TParagraph();
|
||||
paragraph.Run.T := title;
|
||||
paragraph.Run.SetText( title );
|
||||
if ifObj(document_) then Begin
|
||||
id := document_.GetBookMarkID();
|
||||
paragraph.MarkStart.Name := '_Toc' $ id;
|
||||
@@ -10127,14 +10300,7 @@ Type TDocumentBody = Class(DocObject)
|
||||
tcArr union= array(('name':'w:tc','obj':tc,'attrEx':'','nodeType':'','attrName':''));
|
||||
tc.TcPr.Width := colWidth;
|
||||
tc.TcPr.Type := 'dxa';
|
||||
tc.AddText(data[i, j]);
|
||||
{
|
||||
tc.P.pPr.rPr.Lang := 'en-US';
|
||||
tc.P.pPr.rPr.eastAsia := 'zh-CN';
|
||||
tc.P.Run.rPr.Lang := 'en-US';
|
||||
tc.P.Run.rPr.eastAsia := 'zh-CN';
|
||||
tc.P.Run.AddText( getText(data[i, j]) );
|
||||
}
|
||||
tc.SetText(data[i, j]);
|
||||
End;
|
||||
tr.Tc := tcArr;
|
||||
End;
|
||||
@@ -10214,7 +10380,7 @@ Type TDocumentBody = Class(DocObject)
|
||||
picId := getPictureMaxId() + 1;
|
||||
picture.Run.Drawing.WInline.ID := picId;
|
||||
picture.Run.Drawing.WInline.Name := '图片 ' $ picId;
|
||||
picture.Run.Drawing.WInline.Descr := picture.Descr;
|
||||
picture.Run.Drawing.WInline.Descr := class(xlsxXml).CurCodePageToUtf8(picture.Descr);
|
||||
picture.Run.Drawing.WInline.cNvGraphicFramePr.xmlns := 'http://schemas.openxmlformats.org/drawingml/2006/main';
|
||||
picture.Run.Drawing.WInline.cNvGraphicFramePr.noChangeAspect := 1;
|
||||
picture.Run.Drawing.WInline.Graphic.xmlns := 'http://schemas.openxmlformats.org/drawingml/2006/main';
|
||||
@@ -10592,8 +10758,7 @@ Type TDocHeaderFooter = Class(TDocumentBody)
|
||||
class(xlsxXml).CopyRprFormat(run.rPr, font);
|
||||
End
|
||||
else Begin
|
||||
run.space := 'preserve';
|
||||
run.T := r[i];
|
||||
run.SetText( r[i] );
|
||||
class(xlsxXml).CopyRprFormat(Run.rPr, font);
|
||||
End;
|
||||
End;
|
||||
@@ -10848,7 +11013,7 @@ Type TCell = Class(TDocumentBody, TWTc)
|
||||
End;
|
||||
|
||||
///添加文字
|
||||
Function AddText(txt);
|
||||
Function SetText(txt);
|
||||
Begin
|
||||
if not ifString(txt) then
|
||||
lines := array('' $ txt);
|
||||
@@ -10860,7 +11025,7 @@ Type TCell = Class(TDocumentBody, TWTc)
|
||||
newp.pPr.rPr.eastAsia := 'zh-CN';
|
||||
newp.Run.rPr.Lang := 'en-US';
|
||||
newp.Run.rPr.eastAsia := 'zh-CN';
|
||||
newp.Run.T := lines[i];
|
||||
newp.Run.SetText( lines[i] );
|
||||
NewChildNode( array("field":"", "name":"w:p", "obj":newp, "attrEx":"", "nodeType":"") );
|
||||
End;
|
||||
if not istable(lines) then
|
||||
@@ -11169,57 +11334,57 @@ Type TCoreProperties = Class(DocObject)
|
||||
private
|
||||
Function readAuthor();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'dc:creator');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'dc:creator'));
|
||||
End;
|
||||
|
||||
Function readCategory();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'cp:category');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'cp:category'));
|
||||
End;
|
||||
|
||||
Function readDescription();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'dc:description');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'dc:description'));
|
||||
End;
|
||||
|
||||
Function readSubject();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'dc:subject');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'dc:subject'));
|
||||
End;
|
||||
|
||||
Function readTitle();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'dc:title');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'dc:title'));
|
||||
End;
|
||||
|
||||
Function readVersion();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'cp:version');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'cp:version'));
|
||||
End;
|
||||
|
||||
Function readRversion();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'cp:rversion');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'cp:rversion'));
|
||||
End;
|
||||
|
||||
Function readKeyWords();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'cp:keywords');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'cp:keywords'));
|
||||
End;
|
||||
|
||||
Function readLastModifiedBy();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'cp:lastModifiedBy');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'cp:lastModifiedBy'));
|
||||
End;
|
||||
|
||||
Function readCreated();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'dcterms:created');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'dcterms:created'));
|
||||
End;
|
||||
|
||||
Function readModified();
|
||||
Begin
|
||||
return class(xlsxXml).GetNode(node_, 'dcterms:modified');
|
||||
return class(xlsxXml).Utf8ToCurCodePage(class(xlsxXml).GetNode(node_, 'dcterms:modified'));
|
||||
End;
|
||||
|
||||
Function propNode(k);
|
||||
@@ -11231,47 +11396,47 @@ private
|
||||
|
||||
Function writeAuthor(v);
|
||||
Begin
|
||||
return propNode('dc:creator').SetValue(v);
|
||||
return propNode('dc:creator').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeCategory(v);
|
||||
Begin
|
||||
return propNode('cp:category').SetValue(v);
|
||||
return propNode('cp:category').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeDescription(v);
|
||||
Begin
|
||||
return propNode('dc:description').SetValue(v);
|
||||
return propNode('dc:description').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeSubject(v);
|
||||
Begin
|
||||
return propNode('dc:subject').SetValue(v);
|
||||
return propNode('dc:subject').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeTitle(v);
|
||||
Begin
|
||||
return propNode('dc:title').SetValue(v);
|
||||
return propNode('dc:title').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeVersion(v);
|
||||
Begin
|
||||
return propNode('cp:version').SetValue(v);
|
||||
return propNode('cp:version').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeRversion(v);
|
||||
Begin
|
||||
return propNode('cp:rversion').SetValue(v);
|
||||
return propNode('cp:rversion').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeKeyWords(v);
|
||||
Begin
|
||||
return propNode('cp:keywords').SetValue(v);
|
||||
return propNode('cp:keywords').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeLastModifiedBy(v);
|
||||
Begin
|
||||
return propNode('cp:lastModifiedBy').SetValue(v);
|
||||
return propNode('cp:lastModifiedBy').SetValue(class(xlsxXml).CurCodePageToUtf8(v));
|
||||
End;
|
||||
|
||||
Function writeCreated(v);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Version 1.0.4
|
||||
|
||||
Type TSDocxFile = Class
|
||||
///Version: V1.0 2022-09-20
|
||||
///适用于 Microsoft Word docx格式文件
|
||||
@@ -22,7 +24,7 @@ Type TSDocxFile = Class
|
||||
Function Destory();
|
||||
Begin
|
||||
End;
|
||||
|
||||
|
||||
Function init();
|
||||
Begin
|
||||
zipfile_ := new ZipFile();
|
||||
@@ -304,8 +306,10 @@ Type TSDocxFile = Class
|
||||
node := node.NextElement('w:comment');
|
||||
End;
|
||||
c := TOfficeObj('TDocComment');
|
||||
c.p.Run.T := txt;
|
||||
c.p.Run.SetText( txt );
|
||||
c.Author := author;
|
||||
if author and not class(xlsxXml).IsUtf8() then
|
||||
c.Author := class(xlsxXml).CurCodePageToUtf8(author);
|
||||
c.ID := id;
|
||||
xmlfile.FirstChildElement('w:comments').InsertEndChild(c.Marshal());
|
||||
return c;
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
// Version 1.0.4
|
||||
|
||||
Type TSExcelFile = Class
|
||||
///Version: V1.0 2022-08-08
|
||||
///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
|
||||
///纯TSL模块实现
|
||||
///Excel文件读写接口
|
||||
|
||||
//缺省构造函数
|
||||
///缺省构造函数
|
||||
Function Create(); overload;
|
||||
Begin
|
||||
init();
|
||||
End;
|
||||
|
||||
//构造函数,打开已经存在的excel文件
|
||||
//alias: string,文件目录别名
|
||||
//fname: string,文件名
|
||||
///构造函数,打开已经存在的excel文件
|
||||
///alias: string,文件目录别名
|
||||
///fname: string,文件名
|
||||
Function Create(alias, fname); overload;
|
||||
Begin
|
||||
init();
|
||||
@@ -51,9 +53,9 @@ Type TSExcelFile = Class
|
||||
Begin
|
||||
path := ExtractFileDir(ExtractFileDir(PluginPath()));
|
||||
if path[1] = '/' then
|
||||
defaultFileName := path + '\\funcext\\TSOffice\\template\\default.xlsx';
|
||||
else
|
||||
defaultFileName := path + '/funcext/TSOffice/template/default.xlsx';
|
||||
else
|
||||
defaultFileName := path + '\\funcext\\TSOffice\\template\\default.xlsx';
|
||||
return OpenFile('', defaultFileName);
|
||||
End;
|
||||
|
||||
@@ -84,7 +86,12 @@ Type TSExcelFile = Class
|
||||
///返回: array('Sheet1','Sheet2')
|
||||
Function GetSheets();
|
||||
Begin
|
||||
return workbook_.GetSheets();
|
||||
sheets := workbook_.GetSheets();
|
||||
for i:=0 to length(sheets)-1 do
|
||||
begin
|
||||
sheets[i] := class(xlsxXml).Utf8ToCurCodePage(sheets[i]);
|
||||
end
|
||||
return sheets;
|
||||
End;
|
||||
|
||||
///获取工作表数
|
||||
@@ -94,38 +101,36 @@ Type TSExcelFile = Class
|
||||
return workbook_.GetSheetsCount();
|
||||
End;
|
||||
|
||||
///获取工作表名
|
||||
///index: int,工作表索引
|
||||
///返回: string
|
||||
Function GetSheetName(index);
|
||||
Begin
|
||||
name := workbook_.GetSheetName(index);
|
||||
return class(xlsxXml).Utf8ToCurCodePage(name);
|
||||
End;
|
||||
|
||||
///创建新sheet
|
||||
///sheet: string,工作表名称
|
||||
Function NewSheet(sheet);
|
||||
Begin
|
||||
return workbook_.NewSheet(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///删除sheet
|
||||
///sheet: string,工作表名称
|
||||
Function DeleteSheet(sheet);
|
||||
Begin
|
||||
return workbook_.DeleteSheet(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///设置工作表名
|
||||
///sourceName: string, 原工作表名
|
||||
///destName: string,目标工作表名
|
||||
///返回: [err, errinfo]
|
||||
Function SetSheetName(sourceName, destName);
|
||||
Begin
|
||||
return workbook_.SetSheetName(sourceName, destName);
|
||||
End;
|
||||
|
||||
///获取工作表名
|
||||
///index: int,工作表索引
|
||||
///返回: string
|
||||
Function GetSheetName(index);
|
||||
Begin
|
||||
name := workbook_.GetSheets()[index];
|
||||
return ifString(name) ? name : '';
|
||||
End;
|
||||
|
||||
///创建新sheet
|
||||
///sheet: string,工作表名称
|
||||
///返回: [err, info]
|
||||
Function NewSheet(sheet);
|
||||
Begin
|
||||
return workbook_.NewSheet(sheet);
|
||||
End;
|
||||
|
||||
///删除sheet
|
||||
///sheet: string,工作表名称
|
||||
///返回: [err, info]
|
||||
Function DeleteSheet(sheet);
|
||||
Begin
|
||||
return workbook_.DeleteSheet(sheet);
|
||||
return workbook_.SetSheetName(class(xlsxXml).CurCodePageToUtf8(sourceName), class(xlsxXml).CurCodePageToUtf8(destName));
|
||||
End;
|
||||
|
||||
///获取总列数
|
||||
@@ -133,8 +138,7 @@ Type TSExcelFile = Class
|
||||
///返回: int
|
||||
Function TotalCols(sheet);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.TotalCols();
|
||||
return workbook_.TotalCols(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///获取总行数
|
||||
@@ -142,8 +146,7 @@ Type TSExcelFile = Class
|
||||
///返回: int
|
||||
Function TotalRows(sheet);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.TotalRows();
|
||||
return workbook_.TotalRows(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///获取单元格的值
|
||||
@@ -152,9 +155,9 @@ Type TSExcelFile = Class
|
||||
///返回: [err, value:string]
|
||||
Function GetCellValue(sheet, axis);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.GetCellValue(axis);
|
||||
return class(ErrorMessage).Fail();
|
||||
[err, value] := workbook_.GetCellValue(class(xlsxXml).CurCodePageToUtf8(sheet), axis);
|
||||
if not err then return array(err, class(xlsxXml).Utf8ToCurCodePage(value));
|
||||
return array(err, value);
|
||||
End;
|
||||
|
||||
///设置单元格的值
|
||||
@@ -169,8 +172,9 @@ Type TSExcelFile = Class
|
||||
/// 属性s:单元格样式
|
||||
Function SetCellValue(sheet, axis, val, opt);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.SetCellValue(axis, val, opt);
|
||||
sheet_name := class(xlsxXml).CurCodePageToUtf8(sheet);
|
||||
value := class(xlsxXml).CurCodePageToUtf8(val);
|
||||
return workbook_.SetCellValue(sheet_name, axis, value, opt);
|
||||
End;
|
||||
|
||||
///获取富文本格式
|
||||
@@ -179,9 +183,9 @@ Type TSExcelFile = Class
|
||||
///返回: [err, richtxt:string],参见SetCellRichText
|
||||
Function GetCellRichText(sheet, axis);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.GetCellValue(axis, 'RichText');
|
||||
return class(ErrorMessage).Fail();
|
||||
[err, str] := workbook_.GetCellRichText(class(xlsxXml).CurCodePageToUtf8(sheet), axis);
|
||||
if err then return array(err, str);
|
||||
else return array(err, class(xlsxXml).Utf8ToCurCodePage(str));
|
||||
End;
|
||||
|
||||
///设置富文本格式
|
||||
@@ -190,11 +194,13 @@ Type TSExcelFile = Class
|
||||
///richtext: string,xml串或富文本对象TSOfficeObj('TRichText')
|
||||
Function SetCellRichText(sheet, axis, richtext);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then begin
|
||||
o := workbook_.GetSheetObj(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
if ifObj(o) then
|
||||
begin
|
||||
xml := richtext;
|
||||
if ifObj(richtext) then
|
||||
xml := class(xlsxXml).Dom2Xml(richtext.Marshal());
|
||||
return o.SetCellValue(axis, xml, array('t':'s'), 'RichText');
|
||||
return o.SetCellValue(axis, class(xlsxXml).CurCodePageToUtf8(xml), array('t':'s'), 'RichText');
|
||||
end
|
||||
End;
|
||||
|
||||
@@ -207,8 +213,7 @@ Type TSExcelFile = Class
|
||||
/// 用法3:ClearCell('A5', 'D8'); //Clear矩形区间所有单元格
|
||||
Function ClearCell(sheet, topLeft, bottomRight);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then o.ClearCell(topLeft, bottomRight);
|
||||
return workbook_.ClearCell(class(xlsxXml).CurCodePageToUtf8(sheet), topLeft, bottomRight);
|
||||
End;
|
||||
|
||||
///设置公式
|
||||
@@ -217,8 +222,7 @@ Type TSExcelFile = Class
|
||||
///formula: string,公式
|
||||
Function SetCellFormula(sheet, axis, formula);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then o.SetCellFormula(axis, formula);
|
||||
return workbook_.SetCellFormula(class(xlsxXml).CurCodePageToUtf8(sheet), axis, formula);
|
||||
End;
|
||||
|
||||
///获取公式
|
||||
@@ -227,9 +231,7 @@ Type TSExcelFile = Class
|
||||
///返回: [err, formula:string]
|
||||
Function GetCellFormula(sheet, axis);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.GetCellFormula(axis);
|
||||
return class(ErrorMessage).Fail();
|
||||
return workbook_.GetCellFormula(class(xlsxXml).CurCodePageToUtf8(sheet), axis);
|
||||
End;
|
||||
|
||||
///按行赋值
|
||||
@@ -302,8 +304,7 @@ Type TSExcelFile = Class
|
||||
///返回: table
|
||||
Function GetTable(sheet, topLeft, bottomRight);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.Import(topLeft, bottomRight);
|
||||
return workbook_.GetTable(class(xlsxXml).CurCodePageToUtf8(sheet), topLeft, bottomRight);
|
||||
End;
|
||||
|
||||
///插入列,在指定列前插入空白列
|
||||
@@ -311,7 +312,7 @@ Type TSExcelFile = Class
|
||||
///col: string 列名,如: "D"
|
||||
Function InsertCol(sheet, col);
|
||||
Begin
|
||||
return workbook_.InsertCol(sheet, col);
|
||||
return workbook_.InsertCol(class(xlsxXml).CurCodePageToUtf8(sheet), col);
|
||||
End;
|
||||
|
||||
///插入行,在指定行前插入空白行
|
||||
@@ -319,7 +320,7 @@ Type TSExcelFile = Class
|
||||
///row: int
|
||||
Function InsertRow(sheet, row);
|
||||
Begin
|
||||
return workbook_.InsertRow(sheet, row);
|
||||
return workbook_.InsertRow(class(xlsxXml).CurCodePageToUtf8(sheet), row);
|
||||
End;
|
||||
|
||||
///删除列
|
||||
@@ -327,7 +328,7 @@ Type TSExcelFile = Class
|
||||
///col: string,如: "D"
|
||||
Function RemoveCol(sheet, col);
|
||||
Begin
|
||||
return workbook_.RemoveCol(sheet, col);
|
||||
return workbook_.RemoveCol(class(xlsxXml).CurCodePageToUtf8(sheet), col);
|
||||
End;
|
||||
|
||||
///删除行
|
||||
@@ -335,7 +336,7 @@ Type TSExcelFile = Class
|
||||
///row: int
|
||||
Function RemoveRow(sheet, row);
|
||||
Begin
|
||||
return workbook_.RemoveRow(sheet, row);
|
||||
return workbook_.RemoveRow(class(xlsxXml).CurCodePageToUtf8(sheet), row);
|
||||
End;
|
||||
|
||||
///设置行高度
|
||||
@@ -344,7 +345,7 @@ Type TSExcelFile = Class
|
||||
///height: double,行高[0-409]
|
||||
Function SetRowHeight(sheet, row, height);
|
||||
Begin
|
||||
return workbook_.SetRowHeight(sheet, row, height);
|
||||
return workbook_.SetRowHeight(class(xlsxXml).CurCodePageToUtf8(sheet), row, height);
|
||||
End;
|
||||
|
||||
///获取行高度
|
||||
@@ -353,7 +354,7 @@ Type TSExcelFile = Class
|
||||
///返回: double
|
||||
Function GetRowHeight(sheet, row);
|
||||
Begin
|
||||
return workbook_.GetRowHeight(sheet, row);
|
||||
return workbook_.GetRowHeight(class(xlsxXml).CurCodePageToUtf8(sheet), row);
|
||||
End;
|
||||
|
||||
///设置列宽度
|
||||
@@ -363,7 +364,7 @@ Type TSExcelFile = Class
|
||||
///width: double,列宽[0-255]
|
||||
Function SetColWidth(sheet, startCol, endCol, width);
|
||||
Begin
|
||||
return workbook_.SetColWidth(sheet, startCol, endCol, width);
|
||||
return workbook_.SetColWidth(class(xlsxXml).CurCodePageToUtf8(sheet), startCol, endCol, width);
|
||||
End;
|
||||
|
||||
///获取列宽度
|
||||
@@ -372,7 +373,7 @@ Type TSExcelFile = Class
|
||||
///返回: double
|
||||
Function GetColWidth(sheet, col);
|
||||
Begin
|
||||
return workbook_.GetColWidth(sheet, col);
|
||||
return workbook_.GetColWidth(class(xlsxXml).CurCodePageToUtf8(sheet), col);
|
||||
End;
|
||||
|
||||
///设置工作表默认列宽
|
||||
@@ -380,7 +381,7 @@ Type TSExcelFile = Class
|
||||
///width: double
|
||||
Function SetSheetDefaultColWidth(sheet, width);
|
||||
Begin
|
||||
return workbook_.SetSheetDefaultColWidth(sheet, width);
|
||||
return workbook_.SetSheetDefaultColWidth(class(xlsxXml).CurCodePageToUtf8(sheet), width);
|
||||
End;
|
||||
|
||||
///获取工作表默认列宽
|
||||
@@ -388,7 +389,7 @@ Type TSExcelFile = Class
|
||||
///返回: double
|
||||
Function GetSheetDefaultColWidth(sheet);
|
||||
Begin
|
||||
return workbook_.GetSheetDefaultColWidth(sheet);
|
||||
return workbook_.GetSheetDefaultColWidth(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///添加批注
|
||||
@@ -417,7 +418,7 @@ Type TSExcelFile = Class
|
||||
///返回: [err, ChartList]
|
||||
Function GetCharts(sheet);
|
||||
Begin
|
||||
return workbook_.GetCharts(sheet);
|
||||
return workbook_.GetCharts(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///单元格坐标切分
|
||||
@@ -507,8 +508,7 @@ Type TSExcelFile = Class
|
||||
///styleid: string,样式Id
|
||||
Function SetCellStyle(sheet, topLeft, bottomRight, styleid);
|
||||
Begin
|
||||
o := workbook_.GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.SetCellStyle(topLeft, bottomRight, styleid);
|
||||
return workbook_.SetCellStyle(class(xlsxXml).CurCodePageToUtf8(sheet), topLeft, bottomRight, styleid);
|
||||
End;
|
||||
|
||||
///获取单元格样式Id,获取到的Id可以在复制单元格样式时,作为调用 SetCellValue、或SetCellStyle 函数的参数使用。
|
||||
@@ -517,7 +517,7 @@ Type TSExcelFile = Class
|
||||
///返回: styleId: string
|
||||
Function GetCellStyle(sheet, axis);
|
||||
Begin
|
||||
return workbook_.GetCellStyle(sheet, axis);
|
||||
return workbook_.GetCellStyle(class(xlsxXml).CurCodePageToUtf8(sheet), axis);
|
||||
End;
|
||||
|
||||
///设置工作表页眉页脚
|
||||
@@ -534,7 +534,7 @@ Type TSExcelFile = Class
|
||||
///visible: boolean
|
||||
Function SetSheetVisible(sheet, visible);
|
||||
Begin
|
||||
return workbook_.SetSheetVisible(sheet, visible);
|
||||
return workbook_.SetSheetVisible(class(xlsxXml).CurCodePageToUtf8(sheet), visible);
|
||||
End;
|
||||
|
||||
///获取工作表可见性
|
||||
@@ -542,7 +542,7 @@ Type TSExcelFile = Class
|
||||
///visibility: boolean
|
||||
Function GetSheetVisible(sheet);
|
||||
Begin
|
||||
return workbook_.GetSheetVisible(sheet);
|
||||
return workbook_.GetSheetVisible(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///设置行可见性
|
||||
@@ -551,7 +551,7 @@ Type TSExcelFile = Class
|
||||
///visible: boolean
|
||||
Function SetRowVisible(sheet, row, visible)
|
||||
Begin
|
||||
return workbook_.SetRowVisible(sheet, row, visible);
|
||||
return workbook_.SetRowVisible(class(xlsxXml).CurCodePageToUtf8(sheet), row, visible);
|
||||
End;
|
||||
|
||||
///获取工作表行可见性
|
||||
@@ -560,7 +560,7 @@ Type TSExcelFile = Class
|
||||
///返回: [err, visible:boolean]
|
||||
Function GetRowVisble(sheet, row);
|
||||
Begin
|
||||
return workbook_.GetRowVisble(sheet, row);
|
||||
return workbook_.GetRowVisble(class(xlsxXml).CurCodePageToUtf8(sheet), row);
|
||||
End;
|
||||
|
||||
///设置列可见性
|
||||
@@ -571,7 +571,7 @@ Type TSExcelFile = Class
|
||||
Begin
|
||||
[err, col] := ColumnNameToNumber(col);
|
||||
if err then return "Col error.";
|
||||
return workbook_.SetColVisible(sheet, col, visible);
|
||||
return workbook_.SetColVisible(class(xlsxXml).CurCodePageToUtf8(sheet), col, visible);
|
||||
End;
|
||||
|
||||
///获取列可见性
|
||||
@@ -582,7 +582,7 @@ Type TSExcelFile = Class
|
||||
Begin
|
||||
[err, col] := ColumnNameToNumber(col);
|
||||
if err then return array(-1, col);
|
||||
return workbook_.GetColVisble(sheet, col);
|
||||
return workbook_.GetColVisble(class(xlsxXml).CurCodePageToUtf8(sheet), col);
|
||||
End;
|
||||
|
||||
///设置工作表页边距
|
||||
@@ -610,7 +610,7 @@ Type TSExcelFile = Class
|
||||
///vcell: string,右下角坐标
|
||||
Function MergeCell(sheet, hcell, vcell);
|
||||
Begin
|
||||
return workbook_.MergeCell(sheet, hcell, vcell);
|
||||
return workbook_.MergeCell(class(xlsxXml).CurCodePageToUtf8(sheet), hcell, vcell);
|
||||
End;
|
||||
|
||||
///取消合并单元格
|
||||
@@ -619,7 +619,7 @@ Type TSExcelFile = Class
|
||||
///vcell: string,右下角坐标
|
||||
Function UnMergeCell(sheet, hcell, vcell);
|
||||
Begin
|
||||
return workbook_.UnMergeCell(sheet, hcell, vcell);
|
||||
return workbook_.UnMergeCell(class(xlsxXml).CurCodePageToUtf8(sheet), hcell, vcell);
|
||||
End;
|
||||
|
||||
///设置工作表视图属性
|
||||
@@ -649,7 +649,7 @@ Type TSExcelFile = Class
|
||||
Function SetPageLayout(sheet, pageLayout);
|
||||
Begin
|
||||
o := getOj(sheet, 'xlsxPageLayout');
|
||||
if ifObj(o) then return o.SetPageLayout(sheet, pageLayout);
|
||||
if ifObj(o) then return o.SetPageLayout(class(xlsxXml).CurCodePageToUtf8(sheet), pageLayout);
|
||||
End;
|
||||
|
||||
///获取工作表页面设置
|
||||
@@ -665,14 +665,15 @@ Type TSExcelFile = Class
|
||||
///sheet: string,工作表名称
|
||||
Function SetDefaultSheet(sheet);
|
||||
Begin
|
||||
return workbook_.SetDefaultSheet(sheet);
|
||||
return workbook_.SetDefaultSheet(class(xlsxXml).CurCodePageToUtf8(sheet));
|
||||
End;
|
||||
|
||||
///获取默认工作表
|
||||
///返回: string,工作表名称
|
||||
Function GetDefaultSheet();
|
||||
Begin
|
||||
return workbook_.GetDefaultSheet();
|
||||
sheet := workbook_.GetDefaultSheet();
|
||||
return class(xlsxXml).Utf8ToCurCodePage(sheet);
|
||||
End;
|
||||
|
||||
///设置超链接
|
||||
@@ -744,7 +745,7 @@ Type TSExcelFile = Class
|
||||
///row: int,行号
|
||||
Function InsertPageBreak(sheet, row);
|
||||
Begin
|
||||
return workbook_.InsertPageBreak(sheet, row);
|
||||
return workbook_.InsertPageBreak(class(xlsxXml).CurCodePageToUtf8(sheet), row);
|
||||
End;
|
||||
|
||||
///删除指定行分页符
|
||||
@@ -752,7 +753,7 @@ Type TSExcelFile = Class
|
||||
///row: int,行号
|
||||
Function RemovePageBreak(sheet, row);
|
||||
Begin
|
||||
return workbook_.RemovePageBreak(sheet, row);
|
||||
return workbook_.RemovePageBreak(class(xlsxXml).CurCodePageToUtf8(sheet), row);
|
||||
End;
|
||||
|
||||
///添加形状
|
||||
@@ -810,8 +811,9 @@ Type TSExcelFile = Class
|
||||
End;
|
||||
|
||||
private
|
||||
Function getOj(sheetname, objname);
|
||||
Function getOj(sheet, objname);
|
||||
Begin
|
||||
sheetname := class(xlsxXml).CurCodePageToUtf8(sheet);
|
||||
if not ifarray(objMgr_) then objMgr_:= array();
|
||||
k := sheetname + '.' + objname;
|
||||
o := objMgr_[ k ];
|
||||
|
||||
@@ -103,7 +103,7 @@ Type TSChart = Class
|
||||
Function Apply(xmlObj);
|
||||
Begin
|
||||
chartData_.Serialize(IsWord()); //初始化图表数据
|
||||
task := array(('c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t', 'pcdata', chartData_.Title),
|
||||
task := array(('c:chartSpace/c:chart/c:title/c:tx/c:rich/a:p/a:r/a:t', 'pcdata', class(xlsxXml).CurCodePageToUtf8(chartData_.Title)),
|
||||
('c:chartSpace/c:chart/c:plotVisOnly', 'val', chartData_.plotVisOnly),
|
||||
('c:chartSpace/c:chart/c:dispBlanksAs', 'val', chartData_.ShowBlanksAs),
|
||||
('c:chartSpace/c:chart/c:legend', 'Del', ifnil(chartData_.Legend)),
|
||||
|
||||
@@ -303,6 +303,42 @@ Type xlsxXml = Class
|
||||
r1.rFont.cs := _cp(r1.rFont.cs, r2.rFont.cs);
|
||||
End;
|
||||
End;
|
||||
|
||||
class Function CodePage(zw);
|
||||
Begin
|
||||
cp := 'utf8';//默认环境为UTF8格式
|
||||
str := StrToBase64(zw);
|
||||
case str of
|
||||
'1tDOxA==':
|
||||
cp := 'gbk';
|
||||
'5Lit5paH':
|
||||
cp := 'utf8';
|
||||
'pKSk5Q==':
|
||||
cp := 'big5';
|
||||
End;
|
||||
sysparams['CodePage'] := cp;
|
||||
End;
|
||||
|
||||
class Function IsUtf8();
|
||||
Begin
|
||||
if ifnil(sysparams['CodePage']) or sysparams['CodePage'] = 'utf8' then
|
||||
return true;
|
||||
return false;
|
||||
End;
|
||||
|
||||
class Function Utf8ToCurCodePage(str);
|
||||
Begin
|
||||
if ifstring(str) and not class(xlsxXml).IsUtf8() then
|
||||
return UTF8ToAnsi(str);
|
||||
return str;
|
||||
End;
|
||||
|
||||
class Function CurCodePageToUtf8(str);
|
||||
Begin
|
||||
if ifstring(str) and not class(xlsxXml).IsUtf8() then
|
||||
return AnsiToUTF8(str);
|
||||
return str;
|
||||
End;
|
||||
|
||||
//字体属性
|
||||
class Function ReadRprFormat(node);
|
||||
|
||||
@@ -38,7 +38,7 @@ Type TDocxChart = Class(TSChart)
|
||||
</a:graphic>
|
||||
</wp:inline>
|
||||
</w:drawing>
|
||||
</w:r>', integer(chartData_.Width * ETU), integer(chartData_.Height * ETU), chartId_, chartData_.Name, rId_);
|
||||
</w:r>', integer(chartData_.Width * ETU), integer(chartData_.Height * ETU), chartId_, class(xlsxXml).CurCodePageToUtf8(chartData_.Name), rId_);
|
||||
End;
|
||||
|
||||
Function IsWord();override;
|
||||
|
||||
@@ -33,4 +33,11 @@ Apply()函数可以修改属性值,例如:
|
||||
newParagraph.Format.StyleId := StyleId; //设置新段落StyleId
|
||||
newParagraph.Apply();
|
||||
★docx.StyleObject()(TDocxStyles对象),可以用户自己插入段落样式(innerXml串或自定义TDocxStyle对象)。
|
||||
|
||||
*如何设置字符集(中文支持)?
|
||||
★用户的脚本可能是UFT8格式,或可能是GBK码格式,系统提供API自动设置当前字符集环境:
|
||||
class(xlsxXml).CodePage('中文'); //系统检测当前的环境字符集
|
||||
...
|
||||
p.Run.SetText('系统可以自动识别这里的中文字符集(utf8或gbk)!');
|
||||
★不设置,默认当前字符集为UTF8
|
||||
|
||||
@@ -75,16 +75,16 @@ private
|
||||
col_index := 1;
|
||||
if not includeHeader then
|
||||
begin
|
||||
excel_.InsertRow(sheetName_, row);
|
||||
excel_.WorkBook().InsertRow(sheetName_, row);
|
||||
end
|
||||
for i:=begCol to endCol do
|
||||
begin
|
||||
[err, cell] := excel_.CoordinatesToCellName(i, row, false);
|
||||
if includeHeader then
|
||||
name := excel_.GetCellValue(sheetName_, cell)[1];
|
||||
name := excel_.WorkBook().GetCellValue(sheetName_, cell)[1];
|
||||
else begin
|
||||
name := "列" $ col_index++;
|
||||
excel_.SetCellValue(sheetName_, cell, name);
|
||||
excel_.WorkBook().SetCellValue(sheetName_, cell, name);
|
||||
end
|
||||
table_str += fmt('<tableColumn id="{}" name="{}" />', id++, name);
|
||||
end
|
||||
|
||||
@@ -57,19 +57,81 @@ Type xlsxWorkBook = Class
|
||||
End;
|
||||
|
||||
///获取工作表列表
|
||||
///返回: arry()
|
||||
Function GetSheets();
|
||||
Begin
|
||||
return sselect ['name'] from sheetNames_ end;
|
||||
End;
|
||||
|
||||
Function GetSheetName(index);
|
||||
Begin
|
||||
name := GetSheets()[index];
|
||||
return ifString(name) ? name : '';
|
||||
End;
|
||||
|
||||
Function TotalCols(sheet);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.TotalCols();
|
||||
End;
|
||||
|
||||
Function TotalRows(sheet);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.TotalRows();
|
||||
End;
|
||||
|
||||
Function GetCellValue(sheet, axis);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.GetCellValue(axis);
|
||||
return class(ErrorMessage).Fail();
|
||||
End;
|
||||
|
||||
Function SetCellValue(sheet, axis, val, opt);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.SetCellValue(axis, val, opt);
|
||||
End;
|
||||
|
||||
Function GetCellRichText(sheet, axis);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.GetCellValue(axis, 'RichText');
|
||||
return class(ErrorMessage).Fail();
|
||||
End;
|
||||
|
||||
Function ClearCell(sheet, topLeft, bottomRight);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then o.ClearCell(topLeft, bottomRight);
|
||||
End;
|
||||
|
||||
Function SetCellFormula(sheet, axis, formula);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if not o.CellIsExists(axis) then SetCellValue(sheet, axis, '');
|
||||
if ifObj(o) then o.SetCellFormula(axis, formula);
|
||||
End;
|
||||
|
||||
Function GetCellFormula(sheet, axis);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.GetCellFormula(axis);
|
||||
return class(ErrorMessage).Fail();
|
||||
End;
|
||||
|
||||
Function GetTable(sheet, topLeft, bottomRight);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.Import(topLeft, bottomRight);
|
||||
End;
|
||||
|
||||
///创建新sheet
|
||||
///sheet: string,工作表名称
|
||||
///返回: [err, info]
|
||||
Function NewSheet(sheet);
|
||||
Begin
|
||||
lname := LowerCase(sheet);
|
||||
if ifint(sheetIndexMap_[ lname ]) then return class(ErrorMessage).SheetExist('The sheet');
|
||||
if ifint(sheetIndexMap_[ lname ]) then return 'The sheet already exists.';
|
||||
rid := getWorkbookRelsRid();
|
||||
|
||||
//添加文件xl/worksheets/sheetN.xml
|
||||
@@ -89,9 +151,9 @@ Type xlsxWorkBook = Class
|
||||
//设置 xl/workbook.xml
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
node := workbook.FirstChildElement('workbook').FirstChildElement('sheets').InsertEndChild('element','sheet');
|
||||
node.SetAttribute('r:id', rid);
|
||||
node.SetAttribute('sheetId', sheetId);
|
||||
node.SetAttribute('name', sheet);
|
||||
node.SetAttribute('sheetId', sheetId);
|
||||
node.SetAttribute('r:id', rid);
|
||||
//workbook.Print();
|
||||
|
||||
//设置docProps/app.xml
|
||||
@@ -126,7 +188,6 @@ Type xlsxWorkBook = Class
|
||||
sheetIndexMap_[ LowerCase(sheet) ] := sheetsCount_;
|
||||
sheetsCount_ ++;
|
||||
SetDefaultSheet(sheet);
|
||||
return class(ErrorMessage).Ok();
|
||||
End;
|
||||
|
||||
///删除sheet
|
||||
@@ -134,9 +195,9 @@ Type xlsxWorkBook = Class
|
||||
///返回: [err, info]
|
||||
Function DeleteSheet(sheet);
|
||||
Begin
|
||||
if sheetsCount_ <= 1 then return class(ErrorMessage).DeleteFailure();
|
||||
if sheetsCount_ <= 1 then return 'Cant not delete the last sheet.';
|
||||
ind := sheetIndexMap_[ LowerCase(sheet) ];
|
||||
if not ifint(ind) then return class(ErrorMessage).Ok();
|
||||
if not ifint(ind) then return ;
|
||||
|
||||
del := sheetNames_[ind];
|
||||
defaultSheet := GetDefaultSheet();
|
||||
@@ -233,27 +294,29 @@ Type xlsxWorkBook = Class
|
||||
xmlFileObjMap_ := array();
|
||||
|
||||
//设置默认工作表
|
||||
ind := sheetIndexMap_[sheet];
|
||||
sheet_name := LowerCase(sheet);
|
||||
ind := sheetIndexMap_[sheet_name];
|
||||
for k, v in sheetIndexMap_ do
|
||||
Begin
|
||||
if v > ind then sheetIndexMap_[k] := v - 1;
|
||||
End
|
||||
reindex(sheetIndexMap_, array(sheet: nil));
|
||||
reindex(sheetIndexMap_, array(sheet_name: nil));
|
||||
ind--;
|
||||
if ind < 0 then SetDefaultSheet(sheetNames_[0]['name']);
|
||||
else if ind = length(sheetIndexMap_) then SetDefaultSheet(sheetNames_[length(sheetIndexMap_)]['name']);
|
||||
else SetDefaultSheet(sheetNames_[ind]['name']);
|
||||
|
||||
return class(ErrorMessage).Ok();
|
||||
xmlFileObjMap_ := array();
|
||||
|
||||
End;
|
||||
|
||||
Function SetSheetName(sourceName, destName);
|
||||
Begin
|
||||
ind := sheetIndexMap_[ LowerCase(destName) ];
|
||||
if ifint(ind) then return class(ErrorMessage).SheetExist(destName);
|
||||
if ifint(ind) then return destName $ ' already exists.';
|
||||
|
||||
ind := sheetIndexMap_[ LowerCase(sourceName) ];
|
||||
if not ifint(ind) then return class(ErrorMessage).SheetNotExist(sourceName);
|
||||
if not ifint(ind) then return sourceName $ ' does not exists.';
|
||||
|
||||
//设置 xl/workbook.xml
|
||||
workbook := GetXmlFileObj('xl/workbook.xml');
|
||||
@@ -282,7 +345,6 @@ Type xlsxWorkBook = Class
|
||||
sheetNames_[ind]['name'] := destName;
|
||||
reindex(sheetIndexMap_, array(LowerCase(sourceName) : LowerCase(destName)));
|
||||
sheetObjMap_ := array();
|
||||
return class(ErrorMessage).Ok();
|
||||
End;
|
||||
|
||||
Function InsertCol(sheet, col);
|
||||
@@ -309,9 +371,6 @@ Type xlsxWorkBook = Class
|
||||
if ifObj(sObj) then sObj.RemoveRow(row);
|
||||
End;
|
||||
|
||||
///获取图表列表
|
||||
///sheet: string,工作表名称
|
||||
///返回: [err, ChartList]
|
||||
Function GetCharts(sheet);
|
||||
Begin
|
||||
ind := sheetIndexMap_[ LowerCase(sheet) ];
|
||||
@@ -370,6 +429,14 @@ Type xlsxWorkBook = Class
|
||||
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
|
||||
begin
|
||||
ind := sheetIndexMap_[LowerCase(default_sheet_name)];
|
||||
if ind = 0 then default_name := sheetNames_[ind + 1]['name'];
|
||||
else default_name := sheetNames_[ind - 1]['name'];
|
||||
SetDefaultSheet(default_name);
|
||||
end
|
||||
while ifObj(node) do
|
||||
Begin
|
||||
name := node.GetAttribute('name');
|
||||
@@ -407,6 +474,12 @@ Type xlsxWorkBook = Class
|
||||
Begin
|
||||
hidden := visible = 1 ? 0 : 1;
|
||||
sheet_obj := GetSheetObj(sheet);
|
||||
is_exists := sheet_obj.RowIsExists(row);
|
||||
if not is_exists then
|
||||
begin
|
||||
[err, cell] := xlsx_call("CoordinatesToCellName", 1, row);
|
||||
sheet_obj.SetCellValue(cell, '');
|
||||
end
|
||||
sheet_obj.SetAttribute(row, array("hidden": hidden));
|
||||
End
|
||||
|
||||
@@ -421,7 +494,7 @@ Type xlsxWorkBook = Class
|
||||
if not err then
|
||||
return array(0, hidden = '1' ? 0 : 1);
|
||||
end
|
||||
return array(0, 0);
|
||||
return array(0, 1);
|
||||
End
|
||||
|
||||
Function SetColVisible(sheet, col, visible)
|
||||
@@ -577,6 +650,12 @@ Type xlsxWorkBook = Class
|
||||
return default_width;
|
||||
End;
|
||||
|
||||
Function SetCellStyle(sheet, topLeft, bottomRight, styleid);
|
||||
Begin
|
||||
o := GetSheetObj(sheet);
|
||||
if ifObj(o) then return o.SetCellStyle(topLeft, bottomRight, styleid);
|
||||
End;
|
||||
|
||||
Function GetCellStyle(sheet, axis);
|
||||
Begin
|
||||
sheet_obj := GetSheetObj(sheet);
|
||||
|
||||
Reference in New Issue
Block a user