C# Excel Add In: Get active worksheet as XML -
i have working word add in, saves selected part of document (including images, tables, etc) xml string in database. add in can retrieve saved xml strings , insert current position of open document, preserving styling , formatting.
i want same excel. want xml string represents active worksheet, save database , later retrieve xml string , insert worksheet active workbook.
the problem is, can't figure out how obtain xml string, nor can figure out how insert worksheet. have been experimenting , searching hours, no avail.
getting active sheet seems easy:
dynamic sheet = globals.thisaddin.application.activesheet;
but haven't been able further.
for reference, how got xml string in word:
microsoft.office.interop.word.selection currentselection = globals.thisaddin.application.selection; string xmlstring = currentselection.xml;
to insert it, used:
string xmlstring = ...; // read string database. microsoft.office.interop.word.selection currentselection = globals.thisaddin.application.selection; currentselection.insertxml(xmlstring);
take in this sample. in sample converting excel sheet datatable
iterating on rows , cells , converting datatable
string.
Comments
Post a Comment