worbooks以及workbook初次实现
This commit is contained in:
commit
fec9adacd3
|
|
@ -0,0 +1 @@
|
||||||
|
# TSOfficeVba 项目: 基于 TSOffice 项目,以类 VBA 方式,用 TSL 实现对 excel、word 的操作
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
// xlsx := new TSExcelFile();
|
||||||
|
// xlsx.NewFile();
|
||||||
|
// xlsx.OpenFile("", "D:\\temp\\vba_new.xlsx");
|
||||||
|
|
||||||
|
application := new Application();
|
||||||
|
application.Workbooks.Add;
|
||||||
|
Workbooks := application.Workbooks;
|
||||||
|
Workbooks.Open(FileName : "D:/temp/vba_new.xlsx");
|
||||||
|
println("Workbooks.Count = {}", Workbooks.Count);
|
||||||
|
Workbooks[2].Worksheets("sheet2").Activate;
|
||||||
|
Workbooks[2].ActiveSheet.Name;
|
||||||
|
println("fullname 1 = {}", Workbooks[1].FullName);
|
||||||
|
println("fullname 2 = {}", Workbooks[2].FullName);
|
||||||
|
application.Workbooks(2).Close(SaveChanges : true, FileName : "D:/temp/vba_close.xlsx");
|
||||||
|
println("close one, Workbooks.Count = {}", Workbooks.Count);
|
||||||
|
application.Workbooks.Open(FileName : "D:/temp/vba_close.xlsx");
|
||||||
|
println("workbook(2).name = {}", application.Workbooks(2).Name);
|
||||||
|
Workbooks[2].Password := "tinysoft";
|
||||||
|
Workbooks[2].Save();
|
||||||
|
println("Path = {}", Workbooks[2].Path);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
Sheets := application.Sheets;
|
||||||
|
println("sheets.Count = {}", sheets.Count);
|
||||||
|
param := array('After': application.Sheets(Sheets.Count), 'Count': 2);
|
||||||
|
application.Worksheets.Add(param);
|
||||||
|
|
||||||
|
xlsx.SaveAs("", "D:\\temp\\xlsxvba.xlsx");
|
||||||
|
return;
|
||||||
|
|
||||||
|
application.Worksheets(1).Visible := false;
|
||||||
|
Worksheets := application.Worksheets;
|
||||||
|
Worksheets[1].Visible := false;
|
||||||
|
Worksheets['Sheet1'].Visible := false;
|
||||||
|
Worksheets[1].Activate;
|
||||||
|
count := Worksheets.Count;
|
||||||
|
println("Worksheets.Count = {}", count);
|
||||||
|
arr := array("After": Worksheets[1]);
|
||||||
|
application.Worksheets('Sheet1').Copy(arr);
|
||||||
|
|
||||||
|
xlsx.SaveAs("", "D:\\temp\\xlsxvba.xlsx");
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
Type Collection = class
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create();
|
||||||
|
Function SetIgnoreCase(value);
|
||||||
|
Function SetActivate(value);
|
||||||
|
Function GetActivate();
|
||||||
|
Function CalNewName(prefix);
|
||||||
|
Function CompareFunction(index, data);
|
||||||
|
|
||||||
|
Function AddCollection(obj, name);
|
||||||
|
Function RemoveCollection(index);
|
||||||
|
Function Operator[](index);
|
||||||
|
Function GetCount();
|
||||||
|
|
||||||
|
public
|
||||||
|
class Function GetInstance(value);
|
||||||
|
|
||||||
|
private
|
||||||
|
ignorecase_; // 忽略大小写
|
||||||
|
container_; // 容器对象
|
||||||
|
fp_; // 函数指针 -- 用来比较
|
||||||
|
activate_; // 激活的对象
|
||||||
|
|
||||||
|
private
|
||||||
|
static collection_;
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
// ============== 实现 ================= //
|
||||||
|
Function Collection.Create();
|
||||||
|
Begin
|
||||||
|
container_ := ContainerList();
|
||||||
|
ignorecase_ := false;
|
||||||
|
fp_ := FindFunction("CompareFunction", self);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.SetIgnoreCase(value);
|
||||||
|
Begin
|
||||||
|
ignorecase_ := value;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.SetActivate(value);
|
||||||
|
Begin
|
||||||
|
activate_ := self[value];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.GetActivate();
|
||||||
|
Begin
|
||||||
|
return activate_;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.CompareFunction(index, data);
|
||||||
|
Begin
|
||||||
|
return (ifnumber(index) and data.index = index)
|
||||||
|
or data.name = index
|
||||||
|
or (ignorecase_ and lowercase(data.name) = lowercase(index));
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.CalNewName(prefix);
|
||||||
|
Begin
|
||||||
|
len := GetCount() + 1;
|
||||||
|
name := prefix $ len;
|
||||||
|
while container_.Get(name, fp_) do
|
||||||
|
name := prefix $ ++len;
|
||||||
|
return name;
|
||||||
|
End;
|
||||||
|
|
||||||
|
class Function Collection.GetInstance(value);
|
||||||
|
Begin
|
||||||
|
if not istable(collection_) then collection_ := array();
|
||||||
|
if not collection_[value] then
|
||||||
|
collection_[value] := new Collection();
|
||||||
|
return collection_[value];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.AddCollection(obj, name);
|
||||||
|
Begin
|
||||||
|
data := new Data();
|
||||||
|
data.obj := obj;
|
||||||
|
data.name := name;
|
||||||
|
data.index := GetCount() + 1;
|
||||||
|
return container_.Add(data);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.RemoveCollection(index);
|
||||||
|
Begin
|
||||||
|
return container_.Remove(index, fp_);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Collection.GetCount();
|
||||||
|
Begin
|
||||||
|
return container_.Size();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Operator Collection.[](index);
|
||||||
|
Begin
|
||||||
|
ret := container_.Get(index, fp_);
|
||||||
|
return ret ? ret.obj : nil;
|
||||||
|
End;
|
||||||
|
|
||||||
|
// 集合中需要记录的数据
|
||||||
|
Type Data = class
|
||||||
|
obj;
|
||||||
|
name;
|
||||||
|
index;
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
Function ContainerList();
|
||||||
|
Begin
|
||||||
|
return new LinkList();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Type LinkList = class
|
||||||
|
|
||||||
|
private
|
||||||
|
count_;
|
||||||
|
head_;
|
||||||
|
tail_;
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create();
|
||||||
|
Function Add(data);
|
||||||
|
Function Remove(index, fp);
|
||||||
|
Function Size();
|
||||||
|
Function Get(index, fp);
|
||||||
|
Function Find(index, fp);
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function LinkList.Create();
|
||||||
|
Begin
|
||||||
|
head_ := new List(nil);
|
||||||
|
tail_ := head_;
|
||||||
|
count_ := 0;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function LinkList.Add(data);
|
||||||
|
Begin
|
||||||
|
list := new List(data);
|
||||||
|
tail_.next := list;
|
||||||
|
list.prev := tail_;
|
||||||
|
tail_ := list;
|
||||||
|
count_ ++;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function LinkList.Remove(index, fp);
|
||||||
|
Begin
|
||||||
|
node := Find(index, fp);
|
||||||
|
if ifnil(node) then return;
|
||||||
|
if node = tail_ then tail_ := node.prev;
|
||||||
|
else begin
|
||||||
|
node.prev.next := node.next;
|
||||||
|
node.next.prev := node.prev;
|
||||||
|
node := nil;
|
||||||
|
end
|
||||||
|
count_--;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function LinkList.Size();
|
||||||
|
Begin
|
||||||
|
return count_;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function LinkList.Find(index, fp);
|
||||||
|
Begin
|
||||||
|
node := head_.next;
|
||||||
|
while (node) do
|
||||||
|
begin
|
||||||
|
if (fp and fp.do(index, node.data)) or node.data = index then
|
||||||
|
return node;
|
||||||
|
node := node.next;
|
||||||
|
end
|
||||||
|
return nil;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function LinkList.Get(index, fp);
|
||||||
|
Begin
|
||||||
|
node := Find(index, fp);
|
||||||
|
return ifnil(node) ? nil : node.data;
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
||||||
|
Type List = class
|
||||||
|
|
||||||
|
public
|
||||||
|
data;
|
||||||
|
prev;
|
||||||
|
next;
|
||||||
|
|
||||||
|
Function Create(value);
|
||||||
|
Begin
|
||||||
|
data := value;
|
||||||
|
prev := nil;
|
||||||
|
next := nil;
|
||||||
|
End;
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
Type Application = class
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create();
|
||||||
|
Function Init();
|
||||||
|
|
||||||
|
public
|
||||||
|
Property Workbooks read ReadWorkbooks; // Completed
|
||||||
|
Function ReadWorkbooks(index);
|
||||||
|
|
||||||
|
private
|
||||||
|
workbooks_;
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
// ============== 实现 ================= //
|
||||||
|
Function Application.Create();
|
||||||
|
Begin
|
||||||
|
Init();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Application.Init();
|
||||||
|
Begin
|
||||||
|
workbooks_ := new Workbooks();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Application.ReadWorkbooks(index)
|
||||||
|
Begin
|
||||||
|
if ifnil(index) then return workbooks_;
|
||||||
|
return workbooks_[index];
|
||||||
|
End;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,437 @@
|
||||||
|
Type Workbook = class
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create(object, name, fullname);
|
||||||
|
Function Init(object);
|
||||||
|
|
||||||
|
private
|
||||||
|
xlsx_;
|
||||||
|
file_name_;
|
||||||
|
full_name_;
|
||||||
|
collection_;
|
||||||
|
|
||||||
|
public
|
||||||
|
Function AcceptAllChanges();
|
||||||
|
Function Activate();
|
||||||
|
Function AddToFavorite();
|
||||||
|
Function ApplyTheme();
|
||||||
|
Function BreakLink(Name, Type);
|
||||||
|
Function CanCheckIn();
|
||||||
|
Function ChangeFileAccess(Mode, WritePassword, Notify);
|
||||||
|
Function ChangeLink(Name, NewName, Type);
|
||||||
|
Function CheckIn(SaveChanges, Comments, MakePublic);
|
||||||
|
Function CheckInWithVersion(SaveChanges, Comments, MakePublic, VersionType);
|
||||||
|
Function Close(SaveChanges, FileName, RouteWorkbook); // Completed
|
||||||
|
Function ConvertComments();
|
||||||
|
Function CreateForecastSheet(Timeline, Values_, ForecastStart, ForecasetEnd, ConfInt, Seasonality, DataCompletion, Aggregation, ChartType, ShowStatsTable);
|
||||||
|
Function DeleteNumberFormat(NumberFormat);
|
||||||
|
Function EnableConnections();
|
||||||
|
Function EndReview();
|
||||||
|
Function ExclusiveAccess();
|
||||||
|
Function ExportAsFixedFormat (Type, FileName, Quality, IncludeDocProperties, IgnorePrintAreas, From_, To_, OpenAfterPublish, FixedFormatExtClassPtr);
|
||||||
|
Function FollowHyperlink (Address, SubAddress, NewWindow, AddHistory, ExtraInfo, Method, HeaderInfo);
|
||||||
|
Function ForwardMailer();
|
||||||
|
Function GetWorkflowTasks();
|
||||||
|
Function GetWorkflowTemplates();
|
||||||
|
Function HighlightChangesOptions(When, Who, Where_);
|
||||||
|
Function LinkInfo (Name, LinkInfo, Type, EditionRef);
|
||||||
|
Function LinkSources (Type);
|
||||||
|
Function LockServerFile();
|
||||||
|
Function MergeWorkbook (FileName);
|
||||||
|
Function NewWindow();
|
||||||
|
Function OpenLinks(Name, ReadOnly, Type);
|
||||||
|
Function PivotCaches();
|
||||||
|
Function Post();
|
||||||
|
Function PrintOut(From_, To_, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName, IgnorePrintAreas);
|
||||||
|
Function PrintPreview(EnableChanges);
|
||||||
|
Function Protect(Password, Structure, Windows);
|
||||||
|
Function ProtectSharing(FileName, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, SharingPassword, FileFormat);
|
||||||
|
Function PublishToDocs();
|
||||||
|
Function PurgeChangeHistoryNow(Days, SharingPassword);
|
||||||
|
Function RefreshAll();
|
||||||
|
Function RejectAllChanges(When, Who, Where_);
|
||||||
|
Function ReloadAs(Encoding);
|
||||||
|
Function RemoveDocumentInformation(RemoveDocInfoType);
|
||||||
|
Function RemoveUser(Index);
|
||||||
|
Function Reply();
|
||||||
|
Function ReplyAll();
|
||||||
|
Function ReplyWithChanges(ShowMessage);
|
||||||
|
Function ResetColors();
|
||||||
|
Function RunAutoMacros(Which);
|
||||||
|
Function Save(); // Completed
|
||||||
|
Function SaveAs(FileName, FileFormat, Password, WriteResPassword, ReadOnlyRecommended, CreateBackup, AccessMode,
|
||||||
|
ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local); // Completed
|
||||||
|
Function SaveAsXMLData(FileName, Map);
|
||||||
|
Function SaveCopyAs(FileName); // Completed
|
||||||
|
Function SendFaxOverInternet(Recipients, Subject, ShowMessage);
|
||||||
|
Function SendForReview(Recipients, Subject, ShowMessage, IncludeAttachment);
|
||||||
|
Function SendMail(Recipients, Subject, ReturnReceipt);
|
||||||
|
Function SendMailer(FileFormat, Priority);
|
||||||
|
Function SetLinkOnData(Name, Procedure_);
|
||||||
|
Function SetPasswordEncryptionOptions(PasswordEncryptionProvider, PasswordEncryptionAlgorithm, PasswordEncryptionKeyLength, PasswordEncryptionFileProperties);
|
||||||
|
Function ToggleFormsDesign();
|
||||||
|
Function Unprotect(Password);
|
||||||
|
Function UnprotectSharing(SharingPassword);
|
||||||
|
Function UpdateFromFile();
|
||||||
|
Function UpdateLink(Name, Type);
|
||||||
|
Function WebPagePreview();
|
||||||
|
Function XmlImport(Url, ImportMap, Overwrite, Destination);
|
||||||
|
Function XmlImportXml(Data, ImportMap, Overwrite, Destination);
|
||||||
|
|
||||||
|
property AccuracyVersion read ReadAccuracyVersion write WriteAccuracyVersion;
|
||||||
|
property ActiveChart read ReadActiveChart;
|
||||||
|
property ActiveSheet read ReadActiveSheet; // Completed
|
||||||
|
property ActiveSlicer read ReadActiveSlicer;
|
||||||
|
property Application read ReadApplication;
|
||||||
|
property AutoSaveOn read ReadAutoSaveOn write WriteAutoSaveOn;
|
||||||
|
property AutoUpdateFrequency read ReadAutoUpdateSaveChanges write WriteAutoUpdateSaveChanges;
|
||||||
|
property AutoUpdateSaveChanges read ReadAutoUpdateSaveChanges write WriteAutoUpdateSaveChanges;
|
||||||
|
property BuiltinDocumentProperties read ReadBuiltinDocumentProperties; // TODO
|
||||||
|
property CalculationVersion read ReadCalculationVersion; // TODO
|
||||||
|
property CaseSensitive read ReadCaseSensitive; // TODO
|
||||||
|
property ChangeHistoryDuration read ReadChangeHistoryDuration write WirteChangeHistoryDuration;
|
||||||
|
property ChartDataPointTrack read ReadChartDataPointTrack write WriteChartDataPointTrack;
|
||||||
|
property Charts read ReadCharts; // TODO
|
||||||
|
property CheckCompatibility read ReadCheckCompatibility write WriteCheckCompatibility;
|
||||||
|
property CodeName read ReadCodeName;
|
||||||
|
property Colors read ReadColors write WriteColors;
|
||||||
|
property CommandBars read ReadCommandBars;
|
||||||
|
property ConflictResolution read ReadConflictResolution write WriteConflictResolution;
|
||||||
|
property Connections read ReadConnections;
|
||||||
|
property ConnectionsDisabled read ReadConnectionsDisabled;
|
||||||
|
property Container read ReadContainer;
|
||||||
|
property ContentTypeProperties read ReadContentTypeProperties;
|
||||||
|
property CreateBackup read ReadCreateBackup;
|
||||||
|
property Creator read ReadCreator;
|
||||||
|
property CustomDocumentProperties read ReadCustomDocumentProperties write WriteCustomDocumentProperties; // TODO
|
||||||
|
property CustomViews read ReadCustomViews;
|
||||||
|
property CustomXMLParts read ReadCustomXMLParts;
|
||||||
|
property Date1904 read ReadDate1904 write WriteDate1904;
|
||||||
|
property DefaultPivotTableStyle read ReadDefaultPivotTableStyle write WriteDefaultPivotTableStyle;
|
||||||
|
property DefaultSlicerStyle read ReadDefaultSlicerStyle write WriteDefaultSlicerStyle;
|
||||||
|
property DefaultTableStyle read ReadDefaultTableStyle write WriteDefaultTableStyle; // TODO
|
||||||
|
property DefaultTimelineStyle read ReadDefaultTimelineStyle write WriteDefaultTimelineStyle;
|
||||||
|
property DisplayDrawingObjects read ReadDisplayDrawingObjects write WriteDisplayDrawingObjects;
|
||||||
|
property DisplayInkComments read ReadDisplayInkComments write WriteDisplayInkComments;
|
||||||
|
property DocumentInspectors read ReadDocumentInspectors;
|
||||||
|
property DocumentLibraryVersions read ReadDocumentLibraryVersions;
|
||||||
|
property DoNotPromptForConvert read ReadDoNotPromptForConvert write WriteDoNotPromptForConvert;
|
||||||
|
property EnableAutoRecover read ReadEnableAutoRecover write WriteEnableAutoRecover;
|
||||||
|
property EncryptionProvider read ReadEncryptionProvider write WriteEncryptionProvider;
|
||||||
|
property EnvelopeVisible read ReadEnvelopeVisible write WriteEnvelopeVisible;
|
||||||
|
property Excel4IntlMacroSheets read ReadExcel4IntlMacroSheets;
|
||||||
|
property Excel4MacroSheets read ReadExcel4MacroSheets;
|
||||||
|
property Excel8CompatibilityMode read ReadExcel8CompatibilityMode;
|
||||||
|
property FileFormat read ReadFileFormat;
|
||||||
|
property Final read ReadFinal write WriteFinal;
|
||||||
|
property ForceFullCalculation read ReadForceFullCalculation write WriteForceFullCalculation;
|
||||||
|
property FullName read ReadFullName; // Completed
|
||||||
|
property FullNameURLEncoded read ReadFullNameURLEncoded;
|
||||||
|
property HasPassword read ReadHasPassword;
|
||||||
|
property HasVBProject read ReadHasVBProject;
|
||||||
|
property HighlightChangesOnScreen read ReadHighlightChangesOnScreen write WriteHighlightChangesOnScreen;
|
||||||
|
property IconSets read ReadIconSets;
|
||||||
|
property InactiveListBorderVisible read ReadInactiveListBorderVisible write WriteInactiveListBorderVisible;
|
||||||
|
property IsAddin read ReadIsAddin write WriteIsAddin;
|
||||||
|
property IsInplace read ReadIsInplace;
|
||||||
|
property KeepChangeHistory read ReadKeepChangeHistory write WriteKeepChangeHistory;
|
||||||
|
property ListChangesOnNewSheet read ReadListChangesOnNewSheet write WriteListChangesOnNewSheet;
|
||||||
|
property Mailer read ReadMailer write WriteMailer;
|
||||||
|
property Model read ReadModel;
|
||||||
|
property MultiUserEditing read ReadMultiUserEditing;
|
||||||
|
property Name read ReadName;
|
||||||
|
property Names read ReadNames;
|
||||||
|
property Parent read ReadParent;
|
||||||
|
property Password read ReadPassword write WritePassword; // Completed
|
||||||
|
property PasswordEncryptionAlgorithm read ReadPasswordEncryptionAlgorithm;
|
||||||
|
property PasswordEncryptionFileProperties read ReadPasswordEncryptionFileProperties;
|
||||||
|
property PasswordEncryptionKeyLength read ReadPasswordEncryptionKeyLength;
|
||||||
|
property PasswordEncryptionProvider read ReadPasswordEncryptionProvider;
|
||||||
|
property Path read ReadPath;
|
||||||
|
property Permission read ReadPermission;
|
||||||
|
property PersonalViewListSettings read ReadPersonalViewListSettings write WritePersonalViewListSettings;
|
||||||
|
property PersonalViewPrintSettings read ReadPersonalViewPrintSettings write WritePersonalViewPrintSettings;
|
||||||
|
property PivotTables read ReadPivotTables;
|
||||||
|
property PrecisionAsDisplayed read ReadPrecisionAsDisplayed write WritePrecisionAsDisplayed;
|
||||||
|
property ProtectStructure read ReadProtectStructure;
|
||||||
|
property ProtectWindows read ReadProtectWindows;
|
||||||
|
property PublishObjects read ReadPublishObjects;
|
||||||
|
property Queries read ReadQueries;
|
||||||
|
property ReadOnly read ReadReadOnly;
|
||||||
|
property ReadOnlyRecommended read ReadReadOnlyRecommended;
|
||||||
|
property RemovePersonalInformation read ReadRemovePersonalInformation write WriteRemovePersonalInformation;
|
||||||
|
property Research read ReadResearch;
|
||||||
|
property RevisionNumber read ReadRevisionNumber;
|
||||||
|
property Saved read ReadSaved write WriteSaved;
|
||||||
|
property SaveLinkValues read ReadSaveLinkValues write WriteSaveLinkValues;
|
||||||
|
property SensitivityLabel read ReadSensitivityLabel;
|
||||||
|
property ServerPolicy read ReadServerPolicy;
|
||||||
|
property ServerViewableItems read ReadServerViewableItems;
|
||||||
|
property Sheets read ReadSheets; // TODO - 差chartsheet
|
||||||
|
property ShowConflictHistory read ReadShowConflictHistory write WriteShowConflictHistory;
|
||||||
|
property ShowPivotChartActiveFields read ReadShowPivotChartActiveFields write WriteShowPivotChartActiveFields;
|
||||||
|
property ShowPivotTableFieldList read ReadShowPivotTableFieldList write WriteShowPivotTableFieldList;
|
||||||
|
property Signatures read ReadSignatures;
|
||||||
|
property SlicerCaches read ReadSlicerCaches;
|
||||||
|
property SmartDocument read ReadSmartDocument;
|
||||||
|
property Styles read ReadStyles; // TODO
|
||||||
|
property TableStyles read ReadTableStyles;
|
||||||
|
property TemplateRemoveExtData read ReadTemplateRemoveExtData write WriteTemplateRemoveExtData;
|
||||||
|
property Theme read ReadTheme;
|
||||||
|
property UpdateLinks read ReadUpdateLinks write WriteUpdateLinks;
|
||||||
|
property UpdateRemoteReferences read ReadUpdateRemoteReferences write WriteUpdateRemoteReferences;
|
||||||
|
property UserStatus read ReadUserStatus;
|
||||||
|
property UseWildcardsoperty read ReadUseWildcardsoperty;
|
||||||
|
property VBASigned read ReadVBASigned;
|
||||||
|
property VBProject read ReadVBProject;
|
||||||
|
property WebOptions read ReadWebOptions;
|
||||||
|
property Windows read ReadWindows;
|
||||||
|
property Worksheets read ReadWorkSheets; // Completed
|
||||||
|
property WritePassword read ReadWritePassword write WriteWritePassword;
|
||||||
|
property WriteReserved read ReadWriteReserved;
|
||||||
|
property WriteReservedBy read ReadWriteReservedBy;
|
||||||
|
property XmlMaps read ReadXmlMaps;
|
||||||
|
property XmlNamespaces read ReadXmlNamespaces;
|
||||||
|
Function ReadXmlNamespaces();
|
||||||
|
Function ReadXmlMaps();
|
||||||
|
Function ReadWriteReservedBy();
|
||||||
|
Function ReadWriteReserved();
|
||||||
|
Function WriteWritePassword();
|
||||||
|
Function ReadWritePassword();
|
||||||
|
Function ReadWorkSheets(index);
|
||||||
|
Function ReadWindows();
|
||||||
|
Function ReadWebOptions();
|
||||||
|
Function ReadVBProject();
|
||||||
|
Function ReadVBASigned();
|
||||||
|
Function ReadUseWildcardsoperty();
|
||||||
|
Function ReadUseWholeCellCriteria();
|
||||||
|
Function ReadUserStatus();
|
||||||
|
Function WriteUpdateRemoteReferences();
|
||||||
|
Function ReadUpdateRemoteReferences();
|
||||||
|
Function WriteUpdateLinks();
|
||||||
|
Function ReadUpdateLinks();
|
||||||
|
Function ReadTheme();
|
||||||
|
Function WriteTemplateRemoveExtData();
|
||||||
|
Function ReadTemplateRemoveExtData();
|
||||||
|
Function ReadTableStyles();
|
||||||
|
Function ReadStyles();
|
||||||
|
Function ReadSmartDocument();
|
||||||
|
Function ReadSlicerCaches();
|
||||||
|
Function ReadSignatures();
|
||||||
|
Function WriteShowPivotTableFieldList();
|
||||||
|
Function ReadShowPivotTableFieldList();
|
||||||
|
Function WriteShowPivotChartActiveFields();
|
||||||
|
Function ReadShowPivotChartActiveFields();
|
||||||
|
Function WriteShowConflictHistory();
|
||||||
|
Function ReadShowConflictHistory();
|
||||||
|
Function ReadSheets();
|
||||||
|
Function ReadServerViewableItems();
|
||||||
|
Function ReadServerPolicy();
|
||||||
|
Function ReadSensitivityLabel();
|
||||||
|
Function WriteSaveLinkValues();
|
||||||
|
Function ReadSaveLinkValues();
|
||||||
|
Function WriteSaved();
|
||||||
|
Function ReadSaved();
|
||||||
|
Function ReadRevisionNumber();
|
||||||
|
Function ReadResearch();
|
||||||
|
Function WriteRemovePersonalInformation();
|
||||||
|
Function ReadRemovePersonalInformation();
|
||||||
|
Function ReadReadOnlyRecommended();
|
||||||
|
Function ReadReadOnly();
|
||||||
|
Function ReadQueries();
|
||||||
|
Function ReadPublishObjects();
|
||||||
|
Function ReadProtectWindows();
|
||||||
|
Function ReadProtectStructure();
|
||||||
|
Function WritePrecisionAsDisplayed();
|
||||||
|
Function ReadPrecisionAsDisplayed();
|
||||||
|
Function ReadPivotTables();
|
||||||
|
Function WritePersonalViewPrintSettings();
|
||||||
|
Function ReadPersonalViewPrintSettings();
|
||||||
|
Function WritePersonalViewListSettings();
|
||||||
|
Function ReadPersonalViewListSettings();
|
||||||
|
Function ReadPermission();
|
||||||
|
Function ReadPath();
|
||||||
|
Function ReadPasswordEncryptionProvider();
|
||||||
|
Function ReadPasswordEncryptionKeyLength();
|
||||||
|
Function ReadPasswordEncryptionFileProperties();
|
||||||
|
Function ReadPasswordEncryptionAlgorithm();
|
||||||
|
Function WritePassword(passwd);
|
||||||
|
Function ReadPassword();
|
||||||
|
Function ReadParent();
|
||||||
|
Function ReadNames();
|
||||||
|
Function ReadName();
|
||||||
|
Function ReadMultiUserEditing();
|
||||||
|
Function ReadModel();
|
||||||
|
Function WriteMailer();
|
||||||
|
Function ReadMailer();
|
||||||
|
Function WriteListChangesOnNewSheet();
|
||||||
|
Function ReadListChangesOnNewSheet();
|
||||||
|
Function WriteKeepChangeHistory();
|
||||||
|
Function ReadKeepChangeHistory();
|
||||||
|
Function ReadIsInplace();
|
||||||
|
Function WriteIsAddin();
|
||||||
|
Function ReadIsAddin();
|
||||||
|
Function WriteInactiveListBorderVisible();
|
||||||
|
Function ReadInactiveListBorderVisible();
|
||||||
|
Function ReadIconSets();
|
||||||
|
Function WriteHighlightChangesOnScreen();
|
||||||
|
Function ReadHighlightChangesOnScreen();
|
||||||
|
Function ReadHasVBProject();
|
||||||
|
Function ReadHasPassword();
|
||||||
|
Function ReadFullNameURLEncoded();
|
||||||
|
Function ReadFullName();
|
||||||
|
Function WriteForceFullCalculation();
|
||||||
|
Function ReadForceFullCalculation();
|
||||||
|
Function WriteFinal();
|
||||||
|
Function ReadFinal();
|
||||||
|
Function ReadFileFormat();
|
||||||
|
Function ReadExcel8CompatibilityMode();
|
||||||
|
Function ReadExcel4MacroSheets();
|
||||||
|
Function ReadExcel4IntlMacroSheets();
|
||||||
|
Function WriteEnvelopeVisible();
|
||||||
|
Function ReadEnvelopeVisible();
|
||||||
|
Function WriteEncryptionProvider();
|
||||||
|
Function ReadEncryptionProvider();
|
||||||
|
Function WriteEnableAutoRecover();
|
||||||
|
Function ReadEnableAutoRecover();
|
||||||
|
Function WriteDoNotPromptForConvert();
|
||||||
|
Function ReadDoNotPromptForConvert();
|
||||||
|
Function ReadDocumentLibraryVersions();
|
||||||
|
Function ReadDocumentInspectors();
|
||||||
|
Function WriteDisplayInkComments();
|
||||||
|
Function ReadDisplayInkComments();
|
||||||
|
Function WriteDisplayDrawingObjects();
|
||||||
|
Function ReadDisplayDrawingObjects();
|
||||||
|
Function WriteDefaultTimelineStyle();
|
||||||
|
Function ReadDefaultTimelineStyle();
|
||||||
|
Function WriteDefaultTableStyle();
|
||||||
|
Function ReadDefaultTableStyle();
|
||||||
|
Function WriteDefaultSlicerStyle();
|
||||||
|
Function ReadDefaultSlicerStyle();
|
||||||
|
Function WriteDefaultPivotTableStyle();
|
||||||
|
Function ReadDefaultPivotTableStyle();
|
||||||
|
Function WriteDate1904();
|
||||||
|
Function ReadDate1904();
|
||||||
|
Function ReadCustomXMLParts();
|
||||||
|
Function ReadCustomViews();
|
||||||
|
Function WriteCustomDocumentProperties(value);
|
||||||
|
Function ReadCustomDocumentProperties(item);
|
||||||
|
Function ReadCreator();
|
||||||
|
Function ReadCreateBackup();
|
||||||
|
Function ReadContentTypeProperties();
|
||||||
|
Function ReadContainer;
|
||||||
|
Function ReadConnectionsDisabled();
|
||||||
|
Function ReadConnections();
|
||||||
|
Function WriteConflictResolution();
|
||||||
|
Function ReadConflictResolution();
|
||||||
|
Function ReadCommandBars();
|
||||||
|
Function WriteColors(index, value);
|
||||||
|
Function ReadColors(index);
|
||||||
|
Function ReadCodeName();
|
||||||
|
Function ReadCheckCompatibility();
|
||||||
|
Function WriteCheckCompatibility();
|
||||||
|
Function ReadCharts();
|
||||||
|
Function ReadChartDataPointTrack();
|
||||||
|
Function WriteChartDataPointTrack();
|
||||||
|
Function WirteChangeHistoryDuration();
|
||||||
|
Function ReadChangeHistoryDuration();
|
||||||
|
Function ReadCaseSensitive();
|
||||||
|
Function ReadCalculationVersion();
|
||||||
|
Function ReadBuiltinDocumentProperties();
|
||||||
|
Function ReadAutoUpdateSaveChanges();
|
||||||
|
Function WriteAutoUpdateSaveChanges();
|
||||||
|
Function ReadAutoSaveOn();
|
||||||
|
Function WriteAutoSaveOn();
|
||||||
|
Function ReadApplication();
|
||||||
|
Function ReadActiveSlicer();
|
||||||
|
Function ReadActiveSheet();
|
||||||
|
Function ReadActiveChart();
|
||||||
|
Function ReadAccuracyVersion();
|
||||||
|
Function WriteAccuracyVersion(value);
|
||||||
|
|
||||||
|
private
|
||||||
|
worksheets_;
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
// ============== 实现 ================= //
|
||||||
|
Function Workbook.Create(object, name, fullname);
|
||||||
|
Begin
|
||||||
|
xlsx_ := object;
|
||||||
|
file_name_ := name;
|
||||||
|
full_name_ := fullname;
|
||||||
|
collection_ := class(Collection).GetInstance('workbook');
|
||||||
|
Init(object);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.Init(object);
|
||||||
|
Begin
|
||||||
|
worksheets_ := new Worksheets(object, file_name_);
|
||||||
|
End;
|
||||||
|
|
||||||
|
// function
|
||||||
|
Function Workbook.Close(SaveChanges, FileName, RouteWorkbook);
|
||||||
|
Begin
|
||||||
|
if SaveChanges then xlsx_.Save();
|
||||||
|
if FileName then xlsx_.SaveAs("", FileName);
|
||||||
|
collection_.RemoveCollection(file_name_);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.Save();
|
||||||
|
Begin
|
||||||
|
xlsx_.Save();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.SaveAs(FileName, FileFormat, Password, WriteResPassword, ReadOnlyRecommended,
|
||||||
|
CreateBackup, AccessMode, ConflictResolution, AddToMru, TextCodepage, TextVisualLayout, Local);
|
||||||
|
Begin
|
||||||
|
xlsx_.SetPassword(Password);
|
||||||
|
xlsx_.SaveAs("", FileName);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.SaveCopyAs(FileName);
|
||||||
|
Begin
|
||||||
|
xlsx_.SaveAs("", FileName);
|
||||||
|
End;
|
||||||
|
|
||||||
|
// property
|
||||||
|
Function Workbook.ReadWorkSheets(index);
|
||||||
|
Begin
|
||||||
|
if ifnil(index) then return worksheets_;
|
||||||
|
return worksheets_.worksheet(index);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.ReadActiveSheet();
|
||||||
|
Begin
|
||||||
|
return worksheets_.GetCollection().GetActivate();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.ReadFullName();
|
||||||
|
Begin
|
||||||
|
return full_name_;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.ReadFullNameURLEncoded();
|
||||||
|
Begin
|
||||||
|
return full_name_;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.ReadName();
|
||||||
|
Begin
|
||||||
|
return file_name_;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.WritePassword(passwd);
|
||||||
|
Begin
|
||||||
|
xlsx_.SetPassword(passwd);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.ReadPassword();
|
||||||
|
Begin
|
||||||
|
return "******";
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbook.ReadPath();
|
||||||
|
Begin
|
||||||
|
return ExtractFileDir(full_name_);
|
||||||
|
End;
|
||||||
|
|
@ -0,0 +1,80 @@
|
||||||
|
Type Workbooks = class
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create();
|
||||||
|
Function Operator[](index);
|
||||||
|
|
||||||
|
private
|
||||||
|
collection_;
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Add(template); // Completed
|
||||||
|
Function CanCheckOut(FileName);
|
||||||
|
Function CheckOut(FileName);
|
||||||
|
Function Close();
|
||||||
|
Function Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword,
|
||||||
|
IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify,
|
||||||
|
Converter, AddToMru, Local, CorruptLoad); // Completed
|
||||||
|
Function OpenDatabase();
|
||||||
|
Function OpenText();
|
||||||
|
Function OpenXML();
|
||||||
|
|
||||||
|
property Application read ReadApplication;
|
||||||
|
property Count read ReadCount;
|
||||||
|
property Creator read ReadCreator;
|
||||||
|
property Item read ReadItem;
|
||||||
|
property Parent read ReadParent;
|
||||||
|
Function ReadCount(); // Completed
|
||||||
|
Function ReadItem(index); // Completed
|
||||||
|
Function ReadApplication();
|
||||||
|
Function ReadCreator();
|
||||||
|
Function ReadParent();
|
||||||
|
|
||||||
|
private
|
||||||
|
Function AddWorkbook(xlsx, name); // Completed
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
// ============== 实现 ================= //
|
||||||
|
Function Workbooks.Create();
|
||||||
|
Begin
|
||||||
|
collection_ := class(Collection).GetInstance('workbook');
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Operator Workbooks.[](index);
|
||||||
|
Begin
|
||||||
|
return collection_[index];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbooks.Add(template);
|
||||||
|
Begin
|
||||||
|
xlsx := new TSXlsxFile();
|
||||||
|
xlsx.NewFile();
|
||||||
|
AddWorkbook(xlsx, collection_.CalNewName("工作簿"));
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbooks.Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword,
|
||||||
|
IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify,
|
||||||
|
Converter, AddToMru, Local, CorruptLoad); // Completed
|
||||||
|
Begin
|
||||||
|
xlsx := new TSXlsxFile();
|
||||||
|
[err, msg] := xlsx.OpenFile("", FileName, Password);
|
||||||
|
if err then return;
|
||||||
|
AddWorkbook(xlsx, xlsx.FileName());
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbooks.ReadCount();
|
||||||
|
Begin
|
||||||
|
return collection_.GetCount();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbooks.ReadItem(index);
|
||||||
|
Begin
|
||||||
|
return collection_[index];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Workbooks.AddWorkbook(xlsx, fullname);
|
||||||
|
Begin
|
||||||
|
name := ExtractFileName(fullname);
|
||||||
|
collection_.AddCollection(new Workbook(xlsx, name, fullname), name);
|
||||||
|
End;
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
Type Worksheet = class
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create(obj, sheet_name, collection);
|
||||||
|
|
||||||
|
private
|
||||||
|
xlsx_;
|
||||||
|
sheet_name_;
|
||||||
|
collection_;
|
||||||
|
|
||||||
|
private
|
||||||
|
Function CalSheetName();
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Activate(); // Completed
|
||||||
|
Function Copy(arr); // Completed
|
||||||
|
Function Calculate();
|
||||||
|
Function ChartObjects();
|
||||||
|
Function CheckSpelling();
|
||||||
|
Function CircleInvalid();
|
||||||
|
Function ClearArrows();
|
||||||
|
Function Delete();
|
||||||
|
Function Evaluate();
|
||||||
|
Function ExportAsFixedFormat();
|
||||||
|
Function Move();
|
||||||
|
Function OLEObjects();
|
||||||
|
Function Paste();
|
||||||
|
Function PasteSpecial();
|
||||||
|
Function PivotTables();
|
||||||
|
Function PivotTableWizard();
|
||||||
|
Function PrintOut();
|
||||||
|
Function PrintPreview();
|
||||||
|
Function Protect();
|
||||||
|
Function ResetAllPageBreaks();
|
||||||
|
Function SaveAs();
|
||||||
|
Function Scenarios();
|
||||||
|
Function Select();
|
||||||
|
Function SetBackgroundPicture();
|
||||||
|
Function ShowAllData();
|
||||||
|
Function ShowDataForm();
|
||||||
|
Function UnProtect();
|
||||||
|
Function XmlDataQuery();
|
||||||
|
Function XmlMapQuery();
|
||||||
|
|
||||||
|
// VBA Property
|
||||||
|
property Visible write WriteVisible;
|
||||||
|
property Name read ReadName write WriteName;
|
||||||
|
Function WriteVisible(value);
|
||||||
|
Function WriteName(new_name);
|
||||||
|
Function ReadName();
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
// ============== 实现 ================= //
|
||||||
|
Function Worksheet.Create(obj, sheet_name, collection);
|
||||||
|
Begin
|
||||||
|
xlsx_ := obj;
|
||||||
|
sheet_name_ := sheet_name;
|
||||||
|
collection_ := collection;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheet.CalSheetName();
|
||||||
|
Begin
|
||||||
|
count := xlsx_.GetSheetsCount();
|
||||||
|
sheets := xlsx_.GetSheets();
|
||||||
|
name := "Sheet" $ count;
|
||||||
|
while name in sheets do
|
||||||
|
name := "Sheet" $ ++count;
|
||||||
|
return name;
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheet.Activate();
|
||||||
|
Begin
|
||||||
|
collection_.SetActivate(sheet_name_);
|
||||||
|
return xlsx_.SetDefaultSheet(sheet_name_);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheet.Copy(arr);
|
||||||
|
Begin
|
||||||
|
if not istable(arr) then return xlsx_.CopySheet(self.Name, CalSheetName());
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheet.WriteVisible(value);
|
||||||
|
Begin
|
||||||
|
return xlsx_.SetSheetVisible(sheet_name_, value);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheet.WriteName(new_name);
|
||||||
|
Begin
|
||||||
|
return xlsx_.SetSheetName(sheet_name_, new_name);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheet.ReadName();
|
||||||
|
Begin
|
||||||
|
return sheet_name_;
|
||||||
|
End;
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
Type Worksheets = class
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Create(object, name);
|
||||||
|
Function Init();
|
||||||
|
Function Operator[](index);
|
||||||
|
Function GetCollection();
|
||||||
|
|
||||||
|
private
|
||||||
|
xlsx_;
|
||||||
|
collection_;
|
||||||
|
|
||||||
|
public
|
||||||
|
Function Add();
|
||||||
|
Function Add2();
|
||||||
|
Function Copy();
|
||||||
|
Function Delete();
|
||||||
|
Function FillAcrossSheets();
|
||||||
|
Function Move();
|
||||||
|
Function PrintOut();
|
||||||
|
Function PrintPreview();
|
||||||
|
Function Select();
|
||||||
|
|
||||||
|
property worksheet read ReadWorksheet;
|
||||||
|
property Count read ReadCount;
|
||||||
|
Function ReadWorksheet(index);
|
||||||
|
Function ReadCount();
|
||||||
|
|
||||||
|
End;
|
||||||
|
|
||||||
|
// ============== 实现 ================= //
|
||||||
|
Function Worksheets.Create(object, name);
|
||||||
|
Begin
|
||||||
|
xlsx_ := object;
|
||||||
|
collection_ := class(Collection).GetInstance(name $ "worksheet");
|
||||||
|
collection_.SetIgnoreCase(true);
|
||||||
|
Init();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheets.Init();
|
||||||
|
Begin
|
||||||
|
sheets := xlsx_.GetSheets();
|
||||||
|
for k, v in sheets do
|
||||||
|
collection_.AddCollection(new Worksheet(xlsx_, v, collection_), v);
|
||||||
|
collection_.SetActivate(xlsx_.GetDefaultSheet());
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Operator Worksheets.[](index);
|
||||||
|
Begin
|
||||||
|
return collection_[index];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheets.ReadWorksheet(index);
|
||||||
|
Begin
|
||||||
|
return collection_[index];
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheets.ReadCount();
|
||||||
|
Begin
|
||||||
|
return collection_.GetCount();
|
||||||
|
End;
|
||||||
|
|
||||||
|
Function Worksheets.GetCollection();
|
||||||
|
Begin
|
||||||
|
return collection_;
|
||||||
|
End;
|
||||||
Loading…
Reference in New Issue