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
Devin, hi and thanks.
I had already looked at the examples, as I had downloaded the samples browser and in the help documentation. For some reason I can't seem to load the data of even a simple file, when that file resides in the ClientBin folder.
The usage I'm looking for is relatively simple; use an excel file as a data source, however maintain that on the server as it will contain a variety of business rules and values that I don't want the user to have access to.
Although writing ASP.NET/WinForms apps for some time I'm coming to Silverlight RIA from extensive programming in Adobe Actionscript 3 (Flex programming); and what I am talking about was achieved using remoting in AS3, it was clunky and relied upon custom creation of c# dlls that lived on the server and web service calls from a Flash Client in the browser.... At least Silverlight is much nicer to work within from an integration of technologies point of view.
SO all I need is some code that will allow me to open xls on the server, read the file, and utilise the contents as business rules/model prior to binding to some presentation layer. I can't seem to get the file to open!
BTW is the IG Excel component async or sync in it's loading; I ask because if I were to load say and XML file, then I'd do this async with a callback on some loaded event.
Many thanks
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