Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
160
Loading an Excel File in Silverlight
posted

OK. I know it should be simple but I'm just beginning what is going to be a long hard road to writing a silverlight App that does things with Excel. So appologies now for any dumb questions (and future questions)

So, a simple question; what is the best way to load an excel file, and where should that file be placed? CODE NEEDED.

Many TIA

Steve

Parents
No Data
Reply
  • 12631
    posted

    Here is a sample, including code, that shows reading an Excel file:

    http://labs.infragistics.com/silverlight/lobsamples/2010.2/#/Samples/DocumentExport/ImportFromExcel

    In your app you may want to give the end user the ability to open a file from their system.  In that case instead of loading the file from the assembly as the sample above does, you would use the OpenFileDialog to prompt the end user for a file.  When the user closes the dialog, it will give you access to a file stream that you can load using the Excel library.

    Note that there are some security restrictions around how you launch the OpenFileDialog.  It can only be done from a user initialted action, like a buttons click event, and you must show the dialog within something like .5 seconds of the user initiated event firing.

    Hopefully that helps get you started.  Let us know if you have any more questions.

    Devin

Children