OWC11/ASP.NET - create spreadsheet, add to UI and allow user interaction

D

dpoindexter

Hi,

I am trying to use OWC11 with ASP.NET 1.1 to create a Spreadshee
object in code-behind, add it to a asp:placeholder control and the
allow user interaction with the Spreadsheet. Can this be done?

I have ordered Alvin's Bruney's book "The Microsoft Office We
Components Black Book with .NET", but need to get a head start o
development due to the long wait for shipment. Can anyone here help?

Thanks!

Davi
 
A

Alvin Bruney - ASP.NET MVP

Yes, there is a nifty way to do it which involves embedding the server-side
object in the response stream. For instance Response.write("<object clsid
spreadsheet goes here/>"). The full technique is discussed in the black
book.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET
-------------------------------------------------------



dpoindexter said:
Hi,

I am trying to use OWC11 with ASP.NET 1.1 to create a Spreadsheet
object in code-behind, add it to a asp:placeholder control and then
allow user interaction with the Spreadsheet. Can this be done?

I have ordered Alvin's Bruney's book "The Microsoft Office Web
Components Black Book with .NET", but need to get a head start on
development due to the long wait for shipment. Can anyone here help?

Thanks!

David
http://www.officehelp.in/archive/index.php |
http://www.officehelp.in/index/index.php
 
D

dpoindexter

Alvin,

Thanks for the response. I am still waiting on your book to be printe
and delivered from lulu.com, but in the meantime, can you give me a hea
start on how to include a dynamically built Spreadsheet object into th
response? From your post, it just looks like you are simply writin
out the HTML <object> tag using response.write(). That's simple, but
just don't see how to integrate the actual Spreadsheet object. Se
below...how would I get "sheet" into the UI?



Code
-------------------

Dim sheet1 As New SpreadsheetClass
Dim dr As SqlDataReader = 'Code to populate SqlDataReader
Dim columns As Integer = dr.FieldCount
Dim row As Integer = 1
Dim liCounter As Integer

While dr.Read
If row = 1 Then
For liCounter = 0 To columns - 1
sheet1.ActiveSheet.Cells(row, liCounter + 1) = CStr(dr.GetName(liCounter))
Next
End If

For liCounter = 0 To columns - 1
sheet1.ActiveSheet.Cells(row + 1, liCounter + 1) = CStr(dr.GetValue(liCounter))
Next
row += 1
End While

dr.Close()
 
A

Alvin Bruney - MVP ASP.NET

roughly, you would need to do some re-arranging. Here is one quick, good
approach.

write the data to be save out to a file called temp.csv
Response.Write("<object clsid:spreadsheet etc id=sp1</object>");
Response.Write("document.all.sp1.CSVDATA = 'http://localhost/csvdata'");

That code will not compile - it came off the top of my head, but that's the
general idea.

--
Regards,
Alvin Bruney

Shameless Author Plug
[The Microsoft Office Web Components Black Book with .NET]
www.lulu.com/owc, Amazon, Barnes & Noble etc
Forth-coming VSTO.NET
 
D

dpoindexter

Alvin,

Creating flat files on the server is an all around bad approach for ou
solution. So I've tried to think about this a different way. I though
about creating an IHTTPHandler to massage the source data. What sourc
datatypes are acceptable to the Spreadsheet object? That will get m
going in the right direction.

It amazes me there is no way to create, populate and place the objec
on the UI all from code-behind.

Thanks for all your help!

Davi
 
A

Alvin Bruney - MVP ASP.NET

well no, you can actually do it from the code i gave you but it would
require some good old script. roughly, using the same sample, instead of
using a file load you just load it into the cells
Response.Write("document.all.sp1.ActiveRange.Cells[1,2].Value = 'test1'") or
call a method and use a loop to populate the data.

even if you use a handler the spreadsheet does not load an in-memory file.
Files must load thru a valid file path on disk or a url.

--
Regards,
Alvin Bruney

Shameless Author Plug
[The Microsoft Office Web Components Black Book with .NET]
www.lulu.com/owc, Amazon, Barnes & Noble etc
Forth-coming VSTO.NET
 
D

dpoindexter

Alvin,

Thanks for the scripting idea. That may just work for me.

Regarding the HTTP handler, it seems to work fine for the Chart objec
(via XML). Does the Spreadsheet object not accept an XML datasource?

Regards,

Davi
 
A

Alvin Bruney - MVP ASP.NET

yes it does accept xml via XMLDATA. oops, you are right. I just recall that
I have an example in the black book that streams out the csv data and loads
it into the spreadsheet in-memory, that is it doesn't use a file - instead
it piggy backs on the session object. You can give it or try or modify your
chart code, you should just be able to change the object from chart code to
spreadsheet and everything should work fine - fingers seriously crossed.

--
Regards,
Alvin Bruney

Shameless Author Plug
[The Microsoft Office Web Components Black Book with .NET]
www.lulu.com/owc, Amazon, Barnes & Noble etc
Forth-coming VSTO.NET
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top