Create excel file in document library from the data in datatable

Hi ,
I want to generate files dynamically and have then saved to my documetn library instead of  some location on the  harddisk.
I want to generate and excel file  which will read data from the sharepoint list.
Form that data excel will be genereated in the code ,and i want the generated excel directly available in the  document library.
I could use open xml of excel itneroperablity for the excel file generation.
How can i do that.

Hi,
According to your description, you might want to gather data from a SharePoint list as an excel file and upload it to a Document Library.
As you said, you can generate an Excel file using the Open XML SDK, I will provide some information about how to get data from SharePoint list and how to upload files
to a Document Library.
About the retrieving data from a SharePoint list, we can use SharePoint Object Model:
SharePoint Object Model -
SPListItem class
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.aspx 
Add, Update and Delete List Items Programmatically in SharePoint
http://www.mindfiresolutions.com/Add-Update-and-Delete-List-Items-Programmatically-in-Sharepoint-372.php 
About
How to: Upload a File to a SharePoint Site from a Local Folder:
https://msdn.microsoft.com/en-us/library/office/ms454491(v=office.14).aspx
Thanks
Patrick Liang
Forum Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support,
contact [email protected]
Patrick Liang
TechNet Community Support

Similar Messages

  • Create Excel file in application server but the field value is incorrect

    Hi Experts,
    i am facing a problem when create excel file in application server using OPEN DATASET command.
    the internal table have 4 field and one of those field contains 19 digit number --> ICCID.
    the code running well, successfully create EXCELfile in application server but the problem is SAP only copy exactly first 15 digit numeric only and the rest became zero 0
    Example :
    the field value in internal table is 8962118800000447654 but when i opened in the excel file the value became 8962118800000440000.
    and if i add alphabet like a8962118800000447654 then it is correct.
    is there is anything wrong with my code?
    here is my code
    CONSTANTS: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab. "Tab Char
    Data : begin of lt_zdsdmmdt00005 occurs 0,
             SERNR (18) type c,
             MSISDNl(20) type c,
             BOX1 (20) type c,
             ICCID(30) type c,
           end of lt_zdsdmmdt00005.
    data : ld_temp(100) type c.
    i_file = '/usr/sap/DM/test_excel.xls'.
    open dataset i_file for output in legacy text mode.
      loop at lt_zdsdmmdt00005.
        move lt_zdsdmmdt00005-ICCID to ld_iccid .
        concatenate lt_zdsdmmdt00005-sernr  lt_zdsdmmdt00005-MSISDN  lt_zdsdmmdt00005-BOX1 ld_iccid
        into ld_temp separated by c_tab.
        transfer ld_temp to i_file.
      endloop.
      close dataset i_file.
    Best Regard,
    Akbar.

    Hi Naveen,
    thanks for your reply,
    i already tried and the result still the same. any idea?
    Best Regard,
    Akbar.

  • How to read excel file in document library and store excel content in sql table

    Hello,
    Can anyone help me how to read the excel file present in document library and store the content inside excel into sql table?
    Please let me know the ways to acheive this. Feel free to give your suggestions.
    Thanks,
    Cool Developer

    Hi!
    this code i have written becuase i donot find any soltions on net for this , u can try with this . :)
    System.Data.OleDb.
    OleDbConnection ExcelConnection = null;
    FileMode fileMode;
    string filePath = ConfigurationManager.AppSettings["TempLoaction"] + "\\" + fileName;
    using (SPSite _site = new SPSite(SPContext.Current.Web.Url))
    using (SPWeb _web = _site.OpenWeb())
    string docLibrary = ConfigurationManager.AppSettings["DocumentLibrary"];
    SPFile _file = _web.GetFile("/" + docLibrary + "/" + fileName);
    fileMode =
    FileMode.Create;
    byte[] byteArray = _file.OpenBinary();
    MemoryStream dataStream = new MemoryStream(byteArray);
    Stream stream = dataStream;
    using (FileStream fs = File.Open(filePath, fileMode))
    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
    fs.Write(buffer, 0, bytesRead);
    fs.Close();
    //Create the Connection String
    try
    string ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;
    Data Source ='"
    + filePath + "'; Extended Properties=Excel 5.0";
    //Create the connection
    ExcelConnection =
    new System.Data.OleDb.OleDbConnection(ConnectionString);
    //create a string for the query
    string ExcelQuery;
    //Sheet1 is the sheet name
    //create the query:
    //read columns from the Excel file
    ExcelQuery =
    "Select * from [Sheet1$]"; // from Sheet1";
    //use "Select * ... " to select the entire sheet
    //create the command
    System.Data.OleDb.
    OleDbCommand ExcelCommand = new System.Data.OleDb.OleDbCommand(ExcelQuery, ExcelConnection);
    //Open the connection
    ExcelConnection.Open();
    //Create a reader
    System.Data.OleDb.
    OleDbDataReader ExcelReader;
    ExcelReader = ExcelCommand.ExecuteReader();
    //For each row after the first
    while (ExcelReader.Read())
    thanks,
    kshitij

  • Is there a way to create a file merge that updates from the original source file if changes are made?

    I have thousands of PDF documents that are merged with other files. I'll give an example so it's easier to understand.
    File #1 may be merged (or in a portfolio) with Files #2 and #3 but also in another merge (or portfolio) with Files #3 and #4.
    If I update File #1, is there a way for it to automatically update both of the merge or portfolio files with the updated File #1? (File#1 would be replaced, same name and location).
    I'm using windows and Adobe Acrobat Pro

    You would need to add favorites to the WebHelp output prior to creating a CHM. You would need something along the lines of: http://www.wvanweelden.eu/product/favorites-widget-webhelp
    But since it's in a CHM, I'm not sure whether you will be able to save anything from the webhelp output between sessions.
    Kind regards,
    Willam

  • Why would two copies of Lightroom 5 create DNG files with different sizes from the same RAW file? (size is dramatically different, on the order of doubled in size.)

    I have a copy of LIghtroom 5 on my office computer and a personal copy on my home computer. I convert my RAW files to DNG with Lightroom when I import them. Files I shoot for work also get imported on my home workstation. I noticed today that the resulting DNG files for the same RAW image are widely different in size. The ones at home are roughly twice as big as the ones from the office.
    To the best of my knowledge, things are set up the same on both workstations. Any idea what setting might be causing this variation?

    I don't think it's possible to apply lossy compression when importing directly into Lightroom.  I know you can do it with the DNG converter and on export but I don't think this is the case here.
    In which case we need to determine which set-up producing is the "correctly" sized files.  What's the camera and what are the respective file sizes from work and home?

  • Display a document library from the top site on a subsite

    I want to display a document library located on the top site in a webpart located on a subsite.
    I've found different solutions in 2010 but none of them have been possible to achive in 2013.
    The only way that i've got it working in 2013 is described in
    this Stackexchange-post, however this solution will give the webpart it's own ribbon inside of the webpart-frame. 
    Im wondering whether it's possible to achieve this in 2013 OOTB.
    Kr, Rasmus

    Depends, you could use the content search web part to dipslay the document lbirary, bit in that case the result is limited to what's already indexed.
    Kind regards,
    Margriet Bruggeman
    Lois & Clark IT Services
    web site: http://www.loisandclark.eu
    blog: http://www.sharepointdragons.com

  • Can we create TDMS file using C# and retrieve the data using a diadem

    I want to write a tdms file from a dot net application and to use the diadem to retrieve the data and to create a user defined report

    Hello,
    If you want this kind of output, you can use Java Mapping e.g
    1. Create your data type like this:
    CHARSET 0..1
    LOADMODE 0..1
    CODEFORMAT 0..1
    CURRENCY 0..1
    SUPPLIERID_DOMAIN 0..1
    ITEMCOUNT 0..1
    TIMESTAMP 0..1
    UNUOM 0..1
    COMMENTS 0..1
    FIELDNAMES 0..1
    DATA 0..unbounded
    ENDOFDATA
    2.In your message mapping assign all the constants. You might want to concat all the values of the FIELDNAMES and output them to DATA
    3.In your Java Mapping, replace all the XML fields including ,, with ,''',
    4.In ID, do not use FCC.
    Hope this helps,
    Mark

  • How to make html file on server side from the data entered in text area

    Hi!
    I want to know how to make .html file on server side. Like if i enter the data in text area ( or like we normaly see when we write mail that editor) and we can use html tages in it and when user submit form all the data in that field will be saved on server side as an html formate. Is it possible to do so??? or any ruff idea how to design it???

    Erm ...
    Whats the problem with that?!
    Ok, here the code ...
    String myparameter = request.getParameter("paramname");
    String htmltemplate = "<html>\n"
                         +"<head><title>demo</title></head>\n";
                         +"<body>@parametertag@</body>\n";
                         +"<html>";
    String htmlpage = htmltemplate.replaceAll("@parametertag@",myparameter);
    File yourHTMLfile = new File("wheredoyouwannagotoday.html");
    FileOutputStream fos = new FileOutputStream(yourHTMLfile);
    fos.write(htmlpage.getBytes());
    fos.close();You're done.
    Happy Coding! :-) &copy;

  • How to get file fron documents library to the box that enables me to convert it/

    I try to enter a file in the file to convert box and I can't do it. Please give instructions in how to do that.

    If you are using the ExportPDF service from Adobe Reader, did you click on the 'Select PDF file' box?

  • Connect to SharePoint Online Document Library from Excel

    We have a number of people in the field who fill out fairly complex evaluation forms in excel. These forms are submitted to a document library in SharePoint Online
    What I need to be able to do is report off these submitted excel files reading and consolidating specific data (they are all of a consistent format). There may be any number of excel sheets in the source document library
    Previously I would have done this using VBA but I cannot find a way of connecting to a sharepoint online document library from excel vba - I am open to other options

    Hi Karthik,
    Per my understanding, there is an XML file contains attributes. You want to upload it to a SharePoint library as well as extract the values of those attributes to
    save to the corresponding columns of the SharePoint library.
    As it is an Online environment, a workaround I would suggest is that you can create a client application(such as Windows Form Application) to extract values from the
    XML file, then upload the file to SharePoint library, submit the values to the same library afterwards. All this can be achieved using SharePoint Client Object Model.
    How to: Complete basic operations using SharePoint 2013 client library code
    http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
    About how to upload file to SharePoint library using Client Object Model:
    http://blogs.msdn.com/b/sridhara/archive/2010/03/12/uploading-files-using-client-object-model-in-sharepoint-2010.aspx
    About how to read XML from a file by using Visual C#:
    https://support.microsoft.com/en-us/kb/307548?wa=wsignin1.0
    Thanks 
    Patrick Liang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Creating a Folder Within Form or Document Library & Display the name not in the name column.

    I have created a form library that will used to create folders within that. The folder creation is done using an InfoPath Form that has been uploaded to the Form Library. When the new folder was created the name will be displayed at the Name column within
    the Form Library. I want to change that to another column like documents or suchlike.
    Can it be done using InfoPath 2010 VSTA C# or not? If their are other options available please could you try to inform me!
    Thank You,
    Chiranthaka

    Hi,     
    If you want to show the name of folder in another column, a workaround is that you can create an extra column, then create a SharePoint Designer workflow to set the value of
    this column with the name of folder.
    Here is a link about Create Workflow using SharePoint Designer and set field value for your reference:
    http://www.codeproject.com/Tips/419037/Create-Workflow-using-SharePoint-Designer
    I have seen a similar post from you in the link below:
    http://social.technet.microsoft.com/Forums/en-US/c3ff3f17-dbe2-40f9-86c5-ff7d4b663f09/creating-a-folder-within-form-or-document-library-display-the-name-not-in-the-name-column?forum=sharepointcustomizationprevious
    It's recommended that you post a single question in a single thread which will make it easier to be discussed by others.
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to Load the data from excel file(Extension is .CSV) into the temp.table

    Hi
    How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
    My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
    Kindly Suggest the Solution.
    Regards,
    Sachin

    Hello Sachin,
    You can use the following metalink note:How to Read Data from an EXCEL Spreadsheet into a Form Using Webutil Client_OLE2 (Doc ID 813535.1) and modify it a little bit.
    Instead of copy values into forms you can save them in your temporary table.
    Kind regards,
    Alex
    If someone's helpful or correct please mark it accordingly.

  • HT1349 I just purchased  new PC with windows 8.1 and downloaded Itunes, but when I try to add my Music Library from the back up dvd's I created off my old computer it doesn't automatically start the back up process like it did before. How can I "restore"

    I just purchased a new PC with windows 8.1 and downloaded new itunes, but when I try to "restore" my music library from the DVDS i made from my old pc it doesn't automatically restore my library as it used to.  How do I restore my music library from DVDS?

    Thanks but I already did read all of the help notes, which aren't very helpful for this.  I did find out the problem- Apple.....they evidently changed one of the major upsides to their old software- being able to back up your entire library onto dvd's- so you can longer do that or restore from the dvds created from older versions of itunes.  I suspect greed is at play in that Apple now wants you to pay $24.95 per year to use a "cloud" service where they back it up for you.  I can buy a lifetime supply of back up dvds for one year's worth of cloud.  So I am now looking into other music software as I am Appled-out.  There is no reason for them to take away the back up portion of the software other than to sell you thrir cloud service.  As we have already given them a ton of money for 5 Ipods and a bunch of music, I think we have contributed enough.  Time to look to solutions outside of the Apple money tree.  But thank you for reading and replying.

  • How can I keep tabs on the file size when importing from the Event Library into a Project? I want to ensure the movie will fit onto a 4.7Gb disc?

    How can I keep tabs on the file size when importing from the Event Library into a Project? I want to ensure the movie will fit onto a 4.7Gb disc?

    iDVD does not care about file sizes, as it compresses the file to the standard DVD format of mpeg2.
    It only cares about length i.e. max 2 hours including titles etc.
    iDVD encoding settings:
    http://docs.info.apple.com/article.html?path=iDVD/7.0/en/11417.html
    Short version:
    Best Performance is for videos of up to 60 minutes
    Best Quality is for videos of up to 120 minutes
    Professional Quality is also for up to 120 minutes but even higher quality (and takes much longer)
    Professional Quality: The Professional Quality option uses advanced technology to encode your video, resulting in the best quality of video possible on your burned DVD. You can select this option regardless of your project’s duration (up to 2 hours of video for a single-layer disc and 4 hours for a double-layer disc). Because Professional Quality encoding is time-consuming (requiring about twice as much time to encode a project as the High Quality option, for example) choose it only if you are not concerned abo
    In both cases the maximum length includes titles, transitions and effects etc. Allow about 15 minutes for these.
    You can use the amount of video in your project as a rough determination of which method to choose. If your project has an hour or less of video (for a single-layer disc), choose Best Performance. If it has between 1 and 2 hours of video (for a single-layer disc), choose High Quality. If you want the best possible encoding quality for projects that are up to 2 hours (for a single-layer disc), choose Professional Quality. This option takes about twice as long as the High Quality option, so select it only if time is not an issue for you.
    Use the Capacity meter in the Project Info window (choose Project > Project Info) to determine how many minutes of video your project contains.
    NOTE: With the Best Performance setting, you can turn background encoding off by choosing Advanced > “Encode in Background.” The checkmark is removed to show it’s no longer selected. Turning off background encoding can help performance if your system seems sluggish.
    And whilst checking these settings in iDVD Preferences, make sure that the settings for NTSC/PAL and DV/DV Widescreen are also what you want.
    http://support.apple.com/kb/HT1502?viewlocale=en_US

  • Unable to add aspx file to document library using REST and JSOM in SharePoint Hosted App

    Hi,
    I am unable to add an aspx file to document library.  I was actually trying to create a WIKI page and upload to Pages library but that wasn't working so I tried simple document library.  It keeps failing with Access Denied error.  I have checked
    the blocked types and aspx is not included.  I can upload it directly from the browser so that shouldn't be the case.  I have read that it can be achieved with CSOM but I need this to work with a SharePoint Hosted App.  Here is my JSOM:
    factory = new SP.ProxyWebRequestExecutorFactory(appweburl);
        context.set_webRequestExecutorFactory(factory);
        appContextSite = new SP.AppContextSite(context, hostweburl);
        oWeb = appContextSite.get_web();
        oList = oWeb.get_lists().getByTitle('Documents');
        fileCreateInfo = new SP.FileCreationInformation();
        fileCreateInfo.set_url("mywiki.aspx");
        fileCreateInfo.set_content(new SP.Base64EncodedByteArray());
        fileContent = "<%@ Page Inherits=\"Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c\" %> <%@ Reference VirtualPath=\"~TemplatePageUrl\"
    %> <%@ Reference VirtualPath=\"~masterurl/custom.master\" %>";
        for (var i = 0; i < fileContent.length; i++) {
            fileCreateInfo.get_content().append(fileContent.charCodeAt(i));
        newFile = oList.get_rootFolder().get_files().add(fileCreateInfo);
        context.load(newFile);
        context.executeQueryAsync(function () {
            alert('yo');
        }, function (sender, args) {
            alert(args.get_message() + '\n' + args.get_stackTrace());
    If I change the file extension to "txt", it works.  Same with REST implementation, it works with "txt" but fails with "aspx".  Maybe what I am trying to do will not work using JSOM or REST.  Any suggestions?  Your
    help is always appreciated.
    Regards,
    kashif

    Your code works fine in both my on-premises and SharePoint Online. I have given the app full control, so I suspect this is a permissions issue. I would check your permissions on your appmanifest. Must be something to do with publishing permissions. Try
    giving full control and work the permissions down.
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

Maybe you are looking for

  • My iPad won't turn on and I bought it only three days ago :(

    My iPad mini won't turn on. I have it on charge but still nothing. I just bought it three days ago

  • Word processing on mac?

    I'm a relatively new mac user, and I'm just wondering if anyone can tell me if the MacBook comes with any kind of word processing capabilities, because I am a poor college student and can't afford to buy Microsoft Office, unless I have to. If anyone

  • In Design Interactive PDF issue

    Hi I am making a PDF Xmas card, actually an SWF file in which the pages turn when you drag the corners. My issue is that the background colour is white as you can see in the picture. How can I make the background grey or transparent, so that the card

  • Averaging the rows in a 1D array as samples are taken

    I am continuous taking 10 samples of voltage every second and therefore the output (Y) every second is  an array of one column and 10 rows.  How do I create loop that will average the rows of each sample taken.  For example, after 8  seconds I will h

  • "Fails to initialize" on Mac 10.7.4

    Downloaded Configurator 3 today from labs, tried to install, but get a message that it failed to initialize.  Suggests I download Support Advisor, which I did, and that reports nothing wrong. I have Air installed, using it fine with related applicati