Re: C# Office Ubuntu/Windows
"Wolfgang Mauer" <[email protected]> Thu, 3 Nov 2016 10:02:57 +0100
| Newsgroups | gmane.comp.gnome.mono.general |
|---|---|
| Message-ID | <[email protected]> |
Hi all,
i found an “easy way” to manipulate/create ODF. In my case AODL throws exception because it don’t understand .ott:(
This unzip a ott, assign data to user-defined fields and zip to an odt
private void InitDocument(string template, string fileName, IList<IModel> headers, ListStore table, IList<IModel> footers)
{
const string contentFile = "content.xml";
var path = Path.GetTempPath() + fileName;
if (File.Exists(path))
File.Delete(path);
var tmpPath = Path.GetDirectoryName(path) + Path.DirectorySeparatorChar + Guid.NewGuid();
var dirInfo = Directory.CreateDirectory(tmpPath);
ZipFile.ExtractToDirectory(template, dirInfo.FullName);
var xmlDoc = XDocument.Load(dirInfo.FullName + Path.DirectorySeparatorChar + contentFile);
var elements = xmlDoc.Descendants(XName.Get("user-field-decl", "urn:oasis:names:tc:opendocument:xmlns:text:1.0"));
foreach (var element in elements)
{
var attribute = element.Attributes().First(a => a.Name == "text:name");
if (attribute != null)
ApplyData(attribute.Value, headers, table, footers);
}
xmlDoc.Save(dirInfo.FullName + Path.DirectorySeparatorChar + contentFile);
ZipFile.CreateFromDirectory(dirInfo.FullName, path);
dirInfo.Delete(true);
if (Directory.Exists(dirInfo.FullName))
Directory.Delete(dirInfo.FullName);
}
Von: Mono-list [mailto:[email protected]] Im Auftrag von Wolfgang Mauer
Gesendet: Mittwoch, 2. November 2016 14:16
An: 'Marco Ridoni' <[email protected]>; [email protected]
Betreff: Re: [Mono-list] C# Office Ubuntu/Windows
Ok, but if the user choose „saveas“ ? :)
Von: Mono-list [mailto:[email protected]] Im Auftrag von Marco Ridoni
Gesendet: Mittwoch, 2. November 2016 13:41
An: <mailto:[email protected]> [email protected]
Betreff: Re: [Mono-list] C# Office Ubuntu/Windows
2016-11-02 13:37 GMT+01:00 Wolfgang Mauer <[email protected] <mailto:[email protected]> >:
close-listener.
AODL is just a library to generate documents, you can generate it into a temporary directory, read it back into a database and delete the previously-generated copy.
m.
_______________________________________________
Mono-list maillist - [email protected]
http://lists.dot.net/mailman/listinfo/mono-list