I'm trying to test out this DirectOffice library but their demo project is really very limited. I need a little help.
Their library file is quite big which can be found here Demo. But let me just point out some since I'm a bit confuse with the IComparable in assigning the value to the property. I'm trying to compare some C# code and convert the same code in Delphi.
Consider this code (C#):
MainDocumentPart mainDocumentPart = doc.AddMainDocumentPart();
mainDocumentPart.Document = new Document();
Body body = mainDocumentPart.Document.AppendChild(new Body());
Paragraph para = body.AppendChild(new Paragraph());
Run run =para.AppendChild(new Run());
RunProperties runProperties = run.AppendChild(new RunProperties());
FontSize fontSize = new FontSize();
fontSize.Val = "40";
runProperties.AppendChild(fontSize);
run.AppendChild(new Text("Welcome!!!!!"));
mainDocumentPart.Document.Save();
Using the DirectOffice library, it would look like this in Delphi:
MainPart := WordDocument.AddMainDocumentPart;
// create document
Document := CoDocument.Create;
MainPart.Document := Document;
// create body
Body := CoBody.Create;
Document.AppendChild(Body as _OpenXmlElement);
// create paragraph
Paragraph := CoDocumentFormat_OpenXml_Wordprocessing_Paragraph.Create;
Body.AppendChild(Paragraph as _OpenXmlElement);
// create run
Run := CoDocumentFormat_OpenXml_Wordprocessing_Run.Create;
Paragraph.AppendChild(Run as _OpenXmlElement);
Runproperties := CoDocumentFormat_OpenXml_Wordprocessing_RunProperties.Create;
Fontsize := CoDocumentFormat_OpenXml_Wordprocessing_FontSize.Create;
Fontsize.Val := '40'; //this error, Incompatible types: IComparable and string
The last line is obviously a string, I'm not sure how I can convert it to iComparable type.
Base on the DirectOffice.pas library, the following are the declarations. Can someone guide me perhaps in what I can look into next?
_DocumentFormat_OpenXml_Wordprocessing_FontSize = interface(IDispatch)
_DocumentFormat_OpenXml_Wordprocessing_FontSizeDisp = dispinterface
property Val: IComparable read Get_Val write _Set_Val;
Any response is appreciated.
Thanks much!