TSOffice/funcext/TSOffice/worksheet/xlsxPageLayout.tsf

51 lines
1.3 KiB
Plaintext

Type xlsxPageLayout = Class
Function Create(sheetobj, file, xml); overload;
Begin
sheet_ := sheetobj;
file_ := file;
xmlFile_ := xml;
End;
Function SetPageLayout(sheet, pageLayout);
Begin
if ifint(pageLayout.FirstPageNumber) then pageLayout.UseFirstPageNumber := True;
marshal := pageLayout.Marshal();
work_node := xmlFile_.FirstChild('worksheet');
node := work_node.FirstChild('pageSetUp');
if ifObj(node) then work_node.DeleteChild(node);
arr := array('sheetData', 'mergeCells', 'phoneticPr', 'pageMargins');
for i:=length(arr)-1 to 0 do
begin
node := work_node.FirstChild(arr[i]);
if ifObj(node) then
begin
work_node.InsertAfterChild(node, marshal);
flag := 1;
end
end
if not flag then
work_node.InsertEndChild(marshal);
End;
Function GetPageLayout();
Begin
node := xmlFile_.FirstChild('worksheet').FirstChild('pageSetUp');
page_layout := TOfficeObj('TPageLayout');
page_layout.RootObj := node;
return page_layout;
End
class Function NewObject(sheetname, file);
Begin
o := file.WorkBook().GetSheetObj(sheetname);
xml := file.WorkBook().GetSheetXmlfile(sheetname);
if not ifObj(o) then return 0;
return new xlsxPageLayout(o, file, xml);
End;
private
file_; //TSExcelFile对象
sheet_;//XmlSheet对象
xmlFile_; //sheet对应的xml对象
End;