HtmlData in Multiple Excel Sheets

D

dilishtv

Hi All

Can u pls tell me is it possible to fill the data (html string) in
multiple Spreadsheets.
for eg
sheet1.htmldata=htmlstring1
sheet2.htmldata=htmlstring2

Please Help

Thanks in Advance

Dilish
 
A

Alvin Bruney

yup that's basically how it is done. essentially, use the sheetname to
activate the sheet and load data. by default data is loaded to the active
sheet.

--
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 - Wrox/Wiley 2006
 
D

dilishtv

Hi Bruney,

Thank you for ur immediate reply.
Still I could not open it in multiple sheets. Dont know wtz happening

I have created a ExcelObject and added two sheets.
When am asigning objExcel.HtmlData = strHtml
Its showing only one sheet. The second sheet has been deleted
automatically.
I have tried to asign html to a sheet object, but there is no property
for sheet object.

For more details pls refer the following code. & Pleeease let me know
wtz wrong with my code.


<%

Response.Buffer = True
Response.ContentType="application/vnd.ms-excel"

Dim objExcel
Dim excelSheet, sheetNo, totalSheet
Dim iCompanyID, strCompanyName
Dim strDate
dim iRow,iCol,totCols

Set objExcel= Server.CreateObject("OWC10.Spreadsheet")

sRow = " <html> <head> <title>Test Reports</title> "
sRow = sRow & " </head> <body> <table width=710 border=1
cellspacing=3 cellpadding=3 valign=top> <TR> <TD>CompanyID</TD>
<TD>Company Name</TD> <TD>Stock Exchange</TD> </TR>
<TR>
<TD>8377</TD>
<TD><a href="http://www.acc.com"> Acc</a></TD>
<TD>Mumbai</TD>
</TR>
<TR>
<TD>8378</TD>
<TD><a href="http://www.infosys.com">Infosys</a></TD>
<TD>Mumbai</TD>
</TR>
</table> </body> </html> "

objExcel.Sheets.Add
Set excelSheet=objExcel.Worksheets(1)
excelSheet.Activate
objExcel.HTMLData = sRow

' assign to next sheet with a different content

Set excelSheet=objExcel.Worksheets(2)
excelSheet.Activate

'Assign sRow with a different html content and assign to sheet

sRow = " <html> <head> <title>Test Reports</title> "
sRow = sRow & " </head> <body> <table width=710 border=1
cellspacing=3 cellpadding=3 valign=top> <TR> <TD>CompanyID</TD>
<TD>Company Name</TD> <TD>Stock Exchange</TD> </TR>
<TR>
<TD>8377</TD>
<TD><a href="http://www.wipro.com"> Wipro</a></TD>
<TD>Mumbai</TD>
</TR>
<TR>
<TD>8378</TD>
<TD><a href="http://www.hexaware.com">Hexaware</a></TD>
<TD>Mumbai</TD>
</TR>
</table> </body> </html> "

objExcel.HTMLData = sRow

objExcel.DisplayToolbar = false
'excelSheet.Activate
objExcel.AutoFit=true

Response.Write objExcel.XMLData

set objexcel=nothing
%>
 
D

dilishtv

Hi,

Sorry, This code is am testing with

Its showing the excel sheet which I have last binded.

Awaiting for ur reply ..

TIA

Dilish
===========================

<% Language=VBScript %>
<%
Response.Buffer = True
Response.ContentType="application/vnd.ms-excel"

Dim objExcel
Dim excelSheet, sheetNo, totalSheet
Dim iCompanyID, strCompanyName
Dim strDate
dim iRow,iCol,totCols

Set objExcel= Server.CreateObject("OWC10.Spreadsheet")

sRow = " <html> <head> <title>Test Reports</title></head> <body> <table
width=710 border=1 cellspacing=3 cellpadding=3 valign=top> <TR>
<TD>CompanyID</TD> <TD>Company Name</TD><TD>Stock
Exchange</TD></TR><TR><TD>8377</TD><TD><a href='http://www.acc.com'>
Acc</a></TD></TR><TD>8378</TD><TD><a
href='http://www.infosys.com'>Infosys</a></TD><TD>Mumbai</TD></TR></table>
</body> </html> "
Set excelSheet=objExcel.Worksheets(1)
excelSheet.Activate
objExcel.HTMLData = sRow

' assign to next sheet with a different content
objExcel.Sheets.Add
Set excelSheet=objExcel.Worksheets(2)
excelSheet.Activate

'Assign sRow with a different html content and assign to sheet2

sRow = " <html> <head> <title>Test Reports</title></head> <body> <table
width=710 border=1 cellspacing=3 cellpadding=3 valign=top> <TR>
<TD>CompanyID</TD> <TD>Company Name</TD><TD>Stock
Exchange</TD></TR><TR><TD>8377</TD><TD><a href='http://www.wipro.com'>
Wipro</a></TD></TR><TD>8378</TD><TD><a
href='http://www.hexaware.com'>Hexaware</a></TD><TD>Mumbai</TD></TR></table>
</body> </html> "

objExcel.HTMLData = sRow

objExcel.DisplayToolbar = false
'excelSheet.Activate
objExcel.AutoFit=true
Response.Write objExcel.XMLData

set objexcel=nothing

%>

==================
 
A

Alvin Bruney

You need a resource to help you work through your understanding of OWC. At a
quick glance thru your code, there are several things wrong. The most
important of which is that you are using both an OWC object AND changing the
content type of the response object. You neither either one or the other but
not both. I suggest you start by looking at the Office website.

--
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 - Wrox/Wiley 2006
 
D

dilishtv

Thanks once again for ur valueble suggestions.

I have resources abt OWC
but I cant find out a solution regarding these matter anywhere.
Can u pls point out the mistakes in my code.

As it requires HTML Conversion (which Excel do automatically) I have to
use this method
Dont know Is there are any other method.

Pls help me

Dilish
 

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