Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Excel worksheets in asp.net

Reply
Thread Tools

Excel worksheets in asp.net

 
 
DavidC
Guest
Posts: n/a
 
      03-18-2010
I have a process to send data to Excel in a browser window from both a server
control and via dataset code. I would like to create multiple worksheets
(tabs in lower part of Excel spreadsheet) in one xls file. Is that possible?
Below is a sample of code I am using to dump to Excel. Thanks.

Sub ExportDataSetToExcel(ByVal Source As Object, ByVal E As EventArgs)
strExcelSQL = "mc_selPeopleSearchHomeExcel"
Response.Clear()
Response.ContentType = "application/vnd.excel"
Response.Charset = "us-ascii"
Response.AddHeader("content-disposition",
"attachment;filename=search.xls")

Dim gv As New GridView
Using conFileData As SqlConnection = New
SqlConnection(DBClass.GetCoreConnectionString)
conFileData.Open()

Dim ddl As DropDownList =
Page.Master.FindControl("ddlProgramCode")
Dim intProgramID As Int32 = Convert.ToInt32(ddl.SelectedValue)
Dim tb As TextBox = Page.Master.FindControl("txtFindText")

'Get records based on sql
Dim cmdSel As SqlCommand = New SqlCommand(strExcelSQL,
conFileData)
cmdSel.CommandType = Data.CommandType.StoredProcedure

Dim parameter As New SqlParameter()
parameter.ParameterName = "@ProgramID"
parameter.SqlDbType = Data.SqlDbType.Int
parameter.Direction = Data.ParameterDirection.Input
parameter.Value = intProgramID
cmdSel.Parameters.Add(parameter)

parameter = New SqlParameter()
...
...

Dim dtr As SqlDataReader
dtr = cmdSel.ExecuteReader()
gv.DataSource = dtr
gv.DataBind()
dtr.Close()

End Using

Dim sw As New StringWriter()
Dim htw As New System.Web.UI.HtmlTextWriter(sw)
EnableViewState = False
gv.RenderControl(htw)
Response.Write(sw.ToString())
Response.End()
End Sub
--
David
 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      03-18-2010
"DavidC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I have a process to send data to Excel in a browser window from both a
> server
> control and via dataset code. I would like to create multiple worksheets
> (tabs in lower part of Excel spreadsheet) in one xls file. Is that
> possible?


Yes, but not natively:
http://www.aspose.com/categories/pro...y/default.aspx


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

 
Reply With Quote
 
 
 
 
Andy O'Neill
Guest
Posts: n/a
 
      03-19-2010

"DavidC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a process to send data to Excel in a browser window from both a
>server
> control and via dataset code. I would like to create multiple worksheets
> (tabs in lower part of Excel spreadsheet) in one xls file. Is that
> possible?


Yes, but using a different technique.
You can do this with xslt.

 
Reply With Quote
 
DavidC
Guest
Posts: n/a
 
      03-19-2010
"Andy O'Neill" wrote:

>
> "DavidC" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have a process to send data to Excel in a browser window from both a
> >server
> > control and via dataset code. I would like to create multiple worksheets
> > (tabs in lower part of Excel spreadsheet) in one xls file. Is that
> > possible?

>
> Yes, but using a different technique.
> You can do this with xslt.
>
> .
>

Can you point me to where I can find out more about this? Thanks.

David
 
Reply With Quote
 
Andy O'Neill
Guest
Posts: n/a
 
      03-21-2010

"DavidC" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Andy O'Neill" wrote:
>
>>
>> "DavidC" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have a process to send data to Excel in a browser window from both a
>> >server
>> > control and via dataset code. I would like to create multiple
>> > worksheets
>> > (tabs in lower part of Excel spreadsheet) in one xls file. Is that
>> > possible?

>>
>> Yes, but using a different technique.
>> You can do this with xslt.
>>
>> .
>>

> Can you point me to where I can find out more about this? Thanks.
>
> David


If you google on
dataset xslt excel

There are a number of examples.
For all your formatting, the best way is to create an excel spreadsheet like
you want.
Save it as xml and take a look at what you get.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Render TIFF Image from Worksheets, Add Header/Footer to Worksheets sherazam Java 0 11-27-2012 09:26 AM
Need better solution to export from sql server to multiple worksheets in excel in vb.net app Nik ASP .Net 1 03-21-2012 06:43 PM
excel.h - Automating Excel... How to Create new worksheets Jona C++ 2 07-06-2007 03:35 PM
Re: Multiple Worksheets in Excel Thor Microsoft Certification 3 12-22-2006 05:24 AM
Re: Multiple Worksheets in Excel Kurt Microsoft Certification 0 12-15-2006 02:07 AM



Advertisments