Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I will have a master excel file stored in one of the SP list. On the button click I have to create new excel file by reading master template and need to modify some cells and store new file in separate SP List.

Any help or guidance will be much appreciated..

share|improve this question
add comment

3 Answers

Get your master file using,

SPWeb.GetFile method

Then Copy it to create a new file using,

SPFile.CopyTo method (String)

Then,

Modify your newly Excel created file

share|improve this answer
    
Thanks Raja. Do I need to first copy the file into destination list and then open it and modify ? Can't I create first, then modify it and at the end copy to destination list ? –  Rishi Apr 11 '13 at 16:42
    
You can do it both ways, I don't see any problem with that. –  Muhammad Raja Apr 11 '13 at 17:42
add comment

For SharePoint 2010/2013 best option to manipulate Office files programatically, while not resorting to Automation/Interop and 3rd party components is OpenXML (http://excelpackage.codeplex.com/wikipage?title=Using%20a%20template%20to%20create%20an%20Excel%20spreadsheet).

Basically this will help in scenarios where you need to perform more manipulation of the content starting from the actual Master template and even combining more business logic with data from SharePoint.

Alternativelly, using Excel Services could be also used (http://blogs.msdn.com/b/jannemattila/archive/2007/11/06/dynamically-create-static-excel-files-for-excel-service.aspx) however it would require ENterprise license.

share|improve this answer
add comment

You could create a content type with the master file as the template file. Then create a new document of that content type. VBA inside the Excel file can take care of setting values in cells and storing in a different library.

share|improve this answer
    
Thanks Teylyan, Actually my requirement is more complex than I have explained.The new excel file which must be created from master file will display information from the list document based on document selected so I'm afraid content type solution will work for me. –  Rishi Apr 12 '13 at 13:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.