Export to Excel Without Creating File

4 posts, 0 answers
  1. Siward Land
    Siward Land avatar
    10 posts
    Member since:
    Mar 2010

    Posted 26 Sep 2013 Link to this post

    Hi Forum,

    I'm trying to trying to open Excel and populate the worksheet with data without actually saving a *.xlsx a file first from WPF.  When the user clicks on save within Excel, he/she should be prompted with file location selection prompt as no file exists.

    The closest example I've found so far is Telerik's xlsxformatprovider, which is not exactly what i'm looking for.
    http://www.telerik.com/help/wpf/radspreadsheet-model-import-export-xlsxformatprovider-wpf.html

    Does anyone know how to do this?


  2. Anna
    Admin
    Anna avatar
    99 posts

    Posted 27 Sep 2013 Link to this post

    Hi,

    Thank you for your question. I am not a hundred percent sure at what point of your desired scenario is it that you meet difficulties. Is it the population with data or the save file dialog?

    Creating a worksheet without loading it from file first is quite easy through the document model, as you may have already read in the RadSpreadsheet model documentation. You can create a workbook, dynamically add worksheets and modify the cells. All this without loading from any file.

    As to the save file dialog, the easiest way fulfill your requirements would be with the SaveFile Command. As you said, since at this stage the content we have so far is not written on any file, the SaveFile command will automatically prompt the user to choose a file location to save the file. Your XAML should look like this:
    <Button Text="Save"
          Command="{Binding Path=SaveFile.Command}"
          IsEnabled="{Binding Path=SaveFile.IsEnabled}" />

    The data context of the panel can be defined like this:
    DataContext="{Binding Path=CommandDescriptors, ElementName=radSpreadsheet}"

    The important thing to keep in mind is that before you can save .xlsx files, you need to register the respective format provider in the WorkbookFormatProvidersManager like so:
    WorkbookFormatProvidersManager.RegisterFormatProvider(new XlsxFormatProvider());

    I hope this answers your question. In case I have misunderstood you or if you need any further clarifications, please, do not hesitate to get back to us.

    Also, please keep in mind that while interpreting your question, I assumed that by Excel you mean RadSpreadsheet. If you mean MS Excel you might have to search for answers in a forum with more general orientation such as StackOverflow. 

    Regards,
    Anna
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. priyanga
    priyanga avatar
    1 posts
    Member since:
    Feb 2016

    Posted 06 Feb Link to this post

    i wanna know how to modify the telerik spreadsheet and store in database.
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 10 Feb Link to this post

    Hello priyanga,

    Thanks for your interest in RadSpreadsheet.

    I'd recommend going through the following online resources to get started with the control and see how you can achieve the desired task:
    RadSpreadsheet Getting Started - lists the required assemblies you need to add to your project to use the control.
    RadSpreadsheet FirstLook SDK example - demonstrates how you can integrate RadSpreadsheet with RadRibbonView to achieve an Excel-like look.
    Using XlsxFormatProvider - contains examples on how to import a document in the control and export it back to a stream/byte array in order to preserve it in your database.

    I hope this is useful. If there is anything else I can help you with, let me know.

    Regards,
    Petya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top