dantheanswerman
asked on
OPEN XML (ExtremeML) How can I Copy a Workbook
I am trying to copy a workbook in openxml and create a new workbook.
Tried to follow the documentation, but I can't seem to make this work.
Can anyone tell me how to do this... in the code below "TemplateResource" is not recognized and I can't figure out what to use. I tried a file name, and the code runs, but the "input" var is null after its execution.
Tried to follow the documentation, but I can't seem to make this work.
Can anyone tell me how to do this... in the code below "TemplateResource" is not recognized and I can't figure out what to use. I tried a file name, and the code runs, but the "input" var is null after its execution.
public static void CustomizeTemplateToStream()
{
using (var input = Assembly.GetExecutingAssembly().GetManifestResourceStream(TemplateResource))
using (var output = new FileStream("MyWorkbook.xlsx", FileMode.Create, FileAccess.Write))
using (var package = SpreadsheetDocumentWrapper.Open(input, output))
{
// Code here to customize the template workbook
}
}
You don't need to use Excel templates that are embedded in the assembly as resources. You could equally assign any valid System.IO.Stream object to the "input" variable, for example a FileStream that is constructed using the path to file containing your template.
ASKER
OK.. I kind of understand where you're going with this, but am struggling to put it into C# code.
Could you give me some sample code on how to get this done?
Thanks so much... struggling with this.
Could you give me some sample code on how to get this done?
Thanks so much... struggling with this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much.
So for example: MyAssembly.Templates.MyFir