views:

5150

answers:

6

I was wondering if Silverlight 3 can be used to create line of business applications where I can use file import/export facilities, read an xls file and open Excel, use a report tool like Crsytal Reports or Reporting Services or.. is WPF needed?

I am new to Silverlight and WPF and want to decide if I can skip learning WPF. I know Silverlight is a subset of WPF but I just want to concentrate in one of the two.

A: 

No, as far as I know Silverlight 3 is still as sand-boxed as ever. This is becoming a bottleneck for developers though, so I'm sure it will be addressed in upcoming versions of Silverlight.

Jimmy
+1  A: 

No, but unlike Jimmy my guess is that it won't happen in a future. If you need local system there are other technologies to use (e.g. local windows service which can communicate with silverlight app).

The reason why silverlight won't have local access in the nearest future is that Microsoft learned it's lesson with ActiveX.

jarek
You do have access to some of the local system as shown by Sorskoot
Graeme Bradbury
+5  A: 

Although Silverlight is sand-boxed and it isn't possible to open and save files to the local file system direcly, it is possible to get a stream to a local file.

There are the OpenFileDialog and SaveFileDialog classes. These classes make it possible to let the user select a file or location. They return only a stream to that file and do not give any information about the filesystem. This way it's possible to import and export to excel for example.

This example should be enough to get you going.

update: in the meantime I did a small SilverBullet(tm) on the subject on my blog at http://blog.timmykokke.com

Sorskoot
+2  A: 

Silverlight 3 has quite limited file system access. Even though you can save a local file you cannot open it using the associated application directly from Silverlight. If you want the user to export and open an Excel file from a button click in Silverlight you will have to consider alternatives:

  • You can open a new browser window pointed at a URL on your webserver that generates an Excel file. If the server sets the correct content type and the client is properly configured the user will be prompted to open the file in Excel. This effectively moves your export code to the server.
  • You can embed an ActiveX control on the same page as the Silverlight control and using the browser object you can operate this ActiveX control from Silverlight. Given enough rights by the user the ActiveX control can do anything to the local computer including automating Excel.
Martin Liversage
+1  A: 

No, but apparently SL4 does!

Local file access - Silverlight 4

Emrah
A: 

From what I know, SL3 doenst support to use COM application such as Word, Excel, etc.. but SL4 does. If your application is just gonna be used internally, WPF will be the best candidate for your project, but if you want it to be used from the external clients as well, then I reckon you can use SL4, then use OUT OF BROWSER, then it'll work really similar with WPF. Plus with SL4, you're able to interact with Excel, Word, etc... to do lots of things.

Cheers, Brandon

Brandon Truong