.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Save generated xlsx file in document library

Posted By:      Posted Date: October 02, 2010    Points: 0   Category :SharePoint

I have created a webpart that generates a xlsx fil with data from some lists on a sharepoint 2010 site using open xml 2.0.

So far I save the generated xlsx file on the servers harddrive just for test purpose. What I want is to save the generated xlsx file to a document library, but I feel it is a little stupid to save the file on the harddrive and afterwards upload it to the document library.

Can't I skip the "save on harddrive"-step somehow?




View Complete Post

More Related Resource Links

how to automatically save new file into document library with a unique name or ID?

I've created a form using MS Word Document (2007) and lock it (protect it) so that users will be able to fill in the required fields.
then i've created a Content Type and uploaded the MS word form to be used as a template.

Then I've created a document library and enabled the content type and associate the above form for the library, so that when users click on New button the form will open.

everythings goes fine till here.

The problem is when users clicks on New and save the file back to the library, It doesn't save it with a unique name, instead it is over writting the existing one.
in other words, if employee 1 fill up the form and save it and later on employee 2 accessed the library and fill up a new form, he will overwrite what employee 1 has already saved!!

Is there a way to give every new created file a unique name? maybe (username+time)??

Can't save SQL Server Management Studio sql file back into Sharepoint Document Library

I created an sql query file in SQL Server Management Studio and saved it onto my hard drive.  I then moved that file into a Sharepoint Document Library so others on my team could use that query.I opened the file from within sharepoint, it launched SSMS.I made a change to the file and pressed save.here is the error message that comes up."The operation could not be completed.  The process cannot access the file because it is being used by another process"Am I doing something wrong?

Save text box content as a text file in sharepoint 2010 document library


I am a sharepoint developer and currently I am trying to save content of a text box from client side in document library in share point 2010. I have created a sandbox solution for this. I explored the SP2010 client side object model for ECMA script, however I was not able to crack the problem.

I have created the byte array from the text box content and now I want to save it as a text file in the document library using ECMA script.

Kindly suggest how can I achieve that.

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

File Attachments from info-path forms to Sharepoint document library


Hi Experts,

How to upload file attachements from info-path forms to Sharepoint document library?

I need to add attachement from local-PC/Any User to Sharepoint Document Library.


Any help please?? Appreciated




Reg File Upload control to upload files from document library


In Field Upload control if we click browse button it allow us to search file in our hard disk but now as per my requirement as soon as user clicks ‘Browse’ button it should point to the document libraries and their files in site.Let me know how could i achieve this?

Thanks & Regards,


How can I display the notes for a file in a document library?

I have a document library with several office documents in it.  Currently, users select a document and the click the "Tags and Notes" button on the ribbon, then click the "Note Board" tab on the resulting pop-up in order to read or post notes.   What I have been asked for, is a connected web part that would display the notes associated with the currently selected document. The "Note Board" web part does not appear to accept connections.  Am I missing something?  Any ideas? TIA

Uploading a file to a document library produces access denied error, but only on first try.

Hi I have a task which uses a custom form which is part of a custom workflow.  The form incorporates an asp fileUpload control to allow a user to browse for a local file which they can then select and it will be upload a file to a folder in a document library.  The first time this action is performed the folder in the document library will not exist so the code creates a folder and then uploads the file to it. The problem I have is, the first time users try and upload a file the directory is created in the document library as expected, but then the user gets redirected to the standard SharePoint Access Denied page.  If the user goes back to the task list, then loads the task web page again, selects the same file and hits upload, then the file is uploaded fine. All subsequent file uploads work fine after that for all users. Users have Contribute permissions on the document library. The code to do the upload is as follows.  The task has a "CR Number" associated with it, which the directory in the doc library should be called.  It uploads the file to a stream.  Then gets the url of the web and works out the file url and uploads it.  The creation and checking of the folder in the doc library happens in the getDirUrl method. /// <summary> /// Processes an uploaded file. /// </summary> /// <param name="

Event handler that will take an e-mail sent to a doc library and save it as an .MSG file within the

Hi All, I have a requirement to create an event handler that will take an e-mail sent to a doc library and save it as an .MSG file within the library? Any help/inputs on getting this done is much appreciated.  Hanif

Where is the document library setting "Unique file names"?

Live can be so simple if only… ;-).   When using DMS functionality unique file names must be possible. The name is an unimportant attribute when using Meta data. So why can I not choose somewhere in the document library settings something like:   ·         Generate unique filenames Or ·         Do not allow overwrite existing filenames   Maybe in the first service pack?   MS? Please, please, please  

Uploading doc file into SharePoint Document library Programatically.

Hi all, I want to upload the doc file into SharePoint document library using the FileUpload control. For that I am created a new document library in my SharePoint site. But I am not getting the path of Document library where I want to upload the file. Waiting for your valuable response. Regards,-Kaustubh

convert .eml file to .msg file in a document library

Hi All, My requirement is as follows. I have a document library to which users will upload .eml files.On the itemadded event of this doc lib, i'll have to convert the eml file to .msg file. Any help on ways to achieve this is appreciated.Hanif

Convert the .eml file to .msg file in a document library

Hi All, My requirement is as follows. I have a document library to which users will upload .eml files.On the itemadded event of this doc lib, i'll have to convert the eml file to .msg file. Any help on ways to achieve this is appreciated.Hanif

Tagging a file from a document library

Hi,   I'm using the following code to tag a file: SPServiceContext context = SPServiceContext.GetContext(site); SocialTagManager tagManager = new SocialTagManager(context); TaxonomySession taxSession = tagManager.TaxonomySession; TermStore termStore = taxSession.DefaultKeywordsTermStore; Term tag = null; string[] terms = subject.Split(new char[] { separadorAssunto }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < terms.Length; i++) { string termStr = terms[i].Trim(); TermCollection searchTerms = termStore.KeywordsTermSet.GetTerms(termStr, termStore.DefaultLanguage, true); if (searchTerms.Count == 0) { tag = termStore.KeywordsTermSet.CreateTerm(termStr, termStore.DefaultLanguage); } else { tag = searchTerms[0]; } tagManager.AddTag(new Uri(site.Url + fileUrl), tag); Unfortunately, this doesn't work... the file doesn't get tagged. What am I doing wrong?   Thank you!    

Windows 7, Office 2007, and WSS 3.0: Losing file path when saving to Document Library.

A client of ours recently purchased 5 desktops with Windows 7 and Office 2007.  They use Sharepoint to share all documents for their company. The computers that have Windows XP on them can browse the Sharepoint site, open documents (read only or edit), and chose to Save or Save As.  A new window pops open with their current file path of the Sharepoint Document Library so they can save the file in the same folder they opened it from.  I have tested this with Office 2003 and 2007 (Word and Excel) on XP and it always works. The 5 new desktops running Windows 7 cannot do this.  When a user opens a document by browsing to it from Internet Explorer and chooses to Save or Save As, they are kicked back to their last successful save point (usually My Documents or Desktop). The current work around is mapping a drive to the root Document Library directory and having them traverse through the folders to save it back in the original location. I've tried changing the Check Out save settings in Word 2007 and Excel 2007 to edit directly on the server, but I run into the same problem.  I've also made sure that IE sees the site as a Local Intranet site and Protected Mode is off. Any help would be appreciated.  Thanks in advance.

ASP:Upload control . Uploading into a SharePoint Document Library Subfolder and FILE NOT FOUND error

RE: ASP:Upload control . Uploading into a SharePoint Document Library Subfolder and FILE NOT FOUND error Two Issues, apparently unrelated. I have subfolders like this /ApplicantDocuments/20 and /ApplicantDocuments/21 (where 20 and 21 are my subfolders and ApplicantDocuments is my library. 1. The below function is erroring with file not found, but I confirmed I'm sending the fully qualify path (i.e c:\test.txt) to System.IO.FileStream content = System.IO.File.Open(documentFileName, System.IO.FileMode.Open); 2. Even if it worked, looking at the code, I'm not using argument foldername.  I'm passing 20 to the argument. How can I make sure it uploads into subfolder 20 of ApplicantDocuments? Thank you.     Just testing in test environment. Will tighten code once it works.   public void UploadDocumentToSite(string foldername, string documentFileName) {      SPSite siteCollection = new SPSite("https://xxxxxx");      SPWeb web = siteCollection.OpenWeb();      //SPSite.AllowUnsafeUpdates = true;      //Web.AllowUnsafeUpdates = true;      string Lib = "ApplicantDocuments";      SPFolder destFolder = web.GetFolder(Lib);      sendmail(documentFileName+" "+foldername);  

file creation date after uploading document to document library


Hi i am writing a event receiver to get the file creation date after the document is uploaded to the document library.

When a document library is uploaded to a document library the created date is overwriten by the uploaded date.


issues 1) i am not getting the folder path to get the filecreation date for system.io.file.getcreation() method

  public override void ItemAdded(SPItemEventProperties properties)

        properties.ListItem["Created"] =CreationTime(date);
        properties.ListItem["Title"] = itemurl;
      catch (Exception ex)


public CreationTime(SPItemEventProperties properties) {

 using (SPSite site = new SPSite("http://test"))

        SPWeb oWebsiteSrc = site.OpenWeb();

        SPFileCollection fileCollection = oWebsiteSrc.Files ;
        //get the filelocation of the current document library
        string filepath = fileCollection.Web.Lists["test"].Folders.ToString();
        SPList oList = site.AllWebs["jtest"].Lists["test"];
        SPFolder folder=oWebsiteSrc.Files.Folder;

        SPListItem fileitems =oWebsiteSrc.Lists["test"].Items[0] ;
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend