102 lines
3.2 KiB
Plaintext
102 lines
3.2 KiB
Plaintext
Type xlsxSheetView = Class
|
|
Function Create(sheetobj, file, xml); overload;
|
|
Begin
|
|
sheet_ := sheetobj;
|
|
file_ := file;
|
|
xmlFile_ := xml;
|
|
End;
|
|
|
|
Function SetSheetViewOptions(windowsIndex, sheetView);
|
|
Begin
|
|
node := xmlFile_.FirstChild('worksheet').FirstChild('sheetViews');
|
|
sheet_view_node := node.FirstChild('sheetView');
|
|
while ifObj(sheet_view_node) do
|
|
Begin
|
|
id := sheet_view_node.GetAttribute('workbookViewId');
|
|
if trystrtoint(id, r) and r = windowsIndex then
|
|
Begin
|
|
marshal := SheetView.Marshal();
|
|
class(TSXml).UpdateNode(sheet_view_node, marshal['attributes'], array());
|
|
return '';
|
|
End
|
|
sheet_view_node := sheet_view_node.NextElement();
|
|
End
|
|
End;
|
|
|
|
Function GetSheetViewOptions(windowsIndex, sheetView);
|
|
Begin
|
|
node := xmlFile_.FirstChild('worksheet').FirstChild('sheetViews');
|
|
sheet_view_node := node.FirstChild('sheetView');
|
|
while ifObj(sheet_view_node) do
|
|
Begin
|
|
id := sheet_view_node.GetAttribute('workbookViewId');
|
|
if trystrtoint(id, r) and r = windowsIndex then
|
|
Begin
|
|
sheetview := TOfficeObj('TSheetView');
|
|
sheetview.RootObj := sheet_view_node;
|
|
return sheetview;
|
|
End
|
|
sheet_view_node := sheet_view_node.NextElement();
|
|
End
|
|
return nil;
|
|
End
|
|
|
|
Function SetPane(windowsIndex, Pane);
|
|
Begin
|
|
node := xmlFile_.FirstChild('worksheet').FirstChild('sheetViews');
|
|
sheet_view_node := node.FirstChild('sheetView');
|
|
while ifObj(sheet_view_node) do
|
|
Begin
|
|
id := sheet_view_node.GetAttribute('workbookViewId');
|
|
if trystrtoint(id, r) and r = windowsIndex then
|
|
Begin
|
|
sheet_view_node.DeleteChildren();
|
|
sheet_view_node.InsertFirstChild(Pane.Marshal());
|
|
if Pane.XSplit and Pane.YSplit then
|
|
begin
|
|
selection := tofficeobj('TSelection');
|
|
selection.pane := 'topRight';
|
|
selection.activecell := coordinatestocellname(pane.xsplit + 1, 1)[1];
|
|
selection.sqref := selection.activecell;
|
|
sheet_view_node.InsertEndChild(selection.Marshal());
|
|
selection.Pane := 'bottomLeft';
|
|
selection.ActiveCell := CoordinatesToCellName(1, Pane.YSplit + 1)[1];
|
|
selection.Sqref := selection.ActiveCell;
|
|
sheet_view_node.InsertEndChild(selection.Marshal());
|
|
selection := TOfficeObj('TSelection');
|
|
selection.Pane := 'bottomRight';
|
|
sheet_view_node.InsertEndChild(selection.Marshal());
|
|
end
|
|
else if Pane.XSplit then
|
|
begin
|
|
selection := tofficeobj('TSelection');
|
|
selection.pane := 'topRight';
|
|
selection.activecell := coordinatestocellname(pane.xsplit + 1, 2)[1];
|
|
selection.sqref := selection.activecell;
|
|
sheet_view_node.InsertEndChild(selection.Marshal());
|
|
end
|
|
else if Pane.YSplit then
|
|
begin
|
|
selection := tofficeobj('TSelection');
|
|
selection.pane := 'bottomLeft';
|
|
sheet_view_node.InsertEndChild(selection.Marshal());
|
|
end
|
|
End
|
|
sheet_view_node := sheet_view_node.NextElement();
|
|
End
|
|
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 xlsxSheetView(o, file, xml);
|
|
End;
|
|
|
|
private
|
|
[weakref]file_; //TSExcelFile对象
|
|
sheet_;//XmlSheet对象
|
|
xmlFile_; //sheet对应的xml对象
|
|
End;
|