Fog Creek Software
g
Discussion Board




Intranetpage with Excel and saving contents

Hello everybody

I am developing an intranet application where much data will be entered by the users. The nature of the data is such that it would really help, if the data could be entered like in excel. That is series functionality, elegant copy paste of multiple cells, using functions, automatic filling repeated cells and the like. I have thought that there must be some sort of ActiveX component that displays an Excel grid whose data can be somehow transmitted to the webserver. A search on google did not yield any useful links (I might have used the wrong search terms)

If anyone knows something, I'd be very happy

Albert Albani
Thursday, April 1, 2004

Just send up the data in an HTML table with a HTTP content type header of 'application/vnd.ms-excel'  Most browsers will then open the data either with Excel hosted within the browser or running externally.

R1ch
Thursday, April 1, 2004

Yes, but how can I save the altered data back to the webserver?

Displaying the data is not so much of a problem, but the convienient entering of it is.

Albert Albani
Thursday, April 1, 2004

I haven't tried it, but I would guess that you could do it with WebDAV.

R1ch
Thursday, April 1, 2004

I have to do exactly this on my current project. And download it, too.

I'll post back here on Mon/Tues when I've got some sample code working and let you know how its done :)

Justin
Thursday, April 1, 2004

While waiting for Justin's solution, and since you mentionned that this was for an intranet (ie. security is not as big an issue), one idea would be to embed an ActiveX control in an HTML page to display an Excel-like grid (we use ComponentOne's excellent VSFlexGrid, but any OCX should work) in IE.

Then, the user simply clicks on a SAVE button to save the file to a subdirectory under htdocs/ on the web server, ready to be massaged by some script running on the server.

Fred
Thursday, April 1, 2004

OK, halfway there...

This allows your users to download an excel file with data in it.

Create your page with data in it. I used standard <table> elements. ie first <tr> has got <td> with column headers in. Create data in rows.

E.G.
<html> etc headers.....


<table>
<tr>
  <td>CustomerID</td>
</tr>

<!-- loop thru customers, and create tabe row for each
<tr>
  <td>1234</td>
</tr>
</table>

Add the following to the page header. I'm using ASP so I use the Response object.

Response.ContentType="application/excel"
Response.AddHeader "Content-Disposition", "attachment;filename=albert.xls"

Another way of doing this is to create an xls file with all column headers, colours etc in it on the webserver, then populate it dynamically from the client when it has loaded. User has full XL functionality in the browser window. The only problem is that by default it tries (and fails, by design) to save the page back to the webserver.
The above solution is easier to implement.

I'll post part II, uploading, when I've figured that bit out.

Justin
Friday, April 2, 2004

Part II is not available (confidentiality/copyright). You can find the same/similar solution here, though.

http://aspzone.com/articles/160.aspx

Justin
Tuesday, April 6, 2004

*  Recent Topics

*  Fog Creek Home