Hi there,
I have a asp.net page that dynamically constructs a table based on data
retrieved from a database. This is an excerpt of the code used:
' Create a row
Dim row As HtmlTableRow = New HtmlTableRow
' Create a column and add it to the row
Dim cell As HtmlTableCell = New HtmlTableCell
cell.InnerText = sValue
row.Cells.Add(c ell)
' ... other columns created and added...
tblSummaryTable .Rows.Add(row) ' tblSummaryTable already exists on page,
running at server
' ... loop to add more rows as needed...
Now I need to export this table to a spreadsheet when the user clicks a
button on the page.
I have tried a variety of routines, suggestions, etc. None of them have
worked. I only get an empty spreadsheet, sometimes with very wide column (I
don't know why).
Almost all examples I have seen involve the use of datasets/datagrids. For
reasons not relevant to the question, I cannot use datagrids for this.
The question is: Can an HTML table be exported or converted to a spreadsheet
directly (or through a routine, whatever)?
Many thanks,
--
Carlitos 4 1761
This sample is for a GridView, but it should work for any servercontrol:
// you also need this to suppress "not inside Form tag" errors on
RenderControl
public override void VerifyRendering InServerForm(Co ntrol control)
{
// no-op, just override so base doesn't do anything
}
protected void lnkExport_Click (object sender, EventArgs e)
{
Response.Clear( );
Response.AddHea der("content-disposition",
"attachment;fil ename=OvertureR eport.xls");
Response.Charse t = "";
// If you want the option to open the Excel file without saving
than
// uncomment the line below
Response.Cache. SetCacheability (HttpCacheabili ty.NoCache);
Response.Conten tType = "applicatio n/vnd.xls";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite =
new HtmlTextWriter( stringWrite);
gvDomains.Rende rControl(htmlWr ite);
Response.Write( stringWrite.ToS tring());
Response.End();
}
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"Carlitos" wrote:
Hi there,
I have a asp.net page that dynamically constructs a table based on data
retrieved from a database. This is an excerpt of the code used:
' Create a row
Dim row As HtmlTableRow = New HtmlTableRow
' Create a column and add it to the row
Dim cell As HtmlTableCell = New HtmlTableCell
cell.InnerText = sValue
row.Cells.Add(c ell)
' ... other columns created and added...
tblSummaryTable .Rows.Add(row) ' tblSummaryTable already exists on page,
running at server
' ... loop to add more rows as needed...
Now I need to export this table to a spreadsheet when the user clicks a
button on the page.
I have tried a variety of routines, suggestions, etc. None of them have
worked. I only get an empty spreadsheet, sometimes with very wide column (I
don't know why).
Almost all examples I have seen involve the use of datasets/datagrids. For
reasons not relevant to the question, I cannot use datagrids for this.
The question is: Can an HTML table be exported or converted to a spreadsheet
directly (or through a routine, whatever)?
Many thanks,
--
Carlitos
Yes, you can use this free control to export your HTML to Excel, or you can
read about how the source code works and do it yourself: http://SteveOrr.net/articles/ExportPanel.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsider http://SteveOrr.net http://iPhonePlaza.net
"Carlitos" <Ca******@discu ssions.microsof t.comwrote in message
news:27******** *************** ***********@mic rosoft.com...
Hi there,
I have a asp.net page that dynamically constructs a table based on data
retrieved from a database. This is an excerpt of the code used:
' Create a row
Dim row As HtmlTableRow = New HtmlTableRow
' Create a column and add it to the row
Dim cell As HtmlTableCell = New HtmlTableCell
cell.InnerText = sValue
row.Cells.Add(c ell)
' ... other columns created and added...
tblSummaryTable .Rows.Add(row) ' tblSummaryTable already exists on page,
running at server
' ... loop to add more rows as needed...
Now I need to export this table to a spreadsheet when the user clicks a
button on the page.
I have tried a variety of routines, suggestions, etc. None of them have
worked. I only get an empty spreadsheet, sometimes with very wide column
(I
don't know why).
Almost all examples I have seen involve the use of datasets/datagrids.
For
reasons not relevant to the question, I cannot use datagrids for this.
The question is: Can an HTML table be exported or converted to a
spreadsheet
directly (or through a routine, whatever)?
Many thanks,
--
Carlitos
On Feb 4, 1:23*pm, "Steve C. Orr [MCSD, MVP, CSM, ASP Insider]"
<St...@Orr.netw rote:
Yes, you can use this free control to export your HTML to Excel, or you can
read about how the source code works and do it yourself:http://SteveOrr.net/articles/ExportPanel.aspx
--
I hope this helps,
Steve C. Orr,
MCSD, MVP, CSM, ASPInsiderhttp://SteveOrr.nethtt p://iPhonePlaza.net
I have been using Steve's free ExportPanel to export web page to
Word. Really nice, and I strongly recommend. Thank Steve for sharing
for free. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alex |
last post by:
Hi all,
I've seen this noted in many posts, but nothing I've checked out gives
me any clue on how to do this.
Basically as my topic says, I have a DTS and I simply need to export
some data from a table in MS SQL 2000 to an Excel spreadsheet. I also
need to automate this process so it can run nightly and each new day a
new spreadsheet will be on a network share for us to pick-up.
|
by: Regnab |
last post by:
I've got my code working so that it'll count the number of columns in
the table and move across (eg Range A-P and then range Q-W). Problem is
when I get to the end of the single letters and get into AA etc. Have
got an idea of how I could do it by using Chr() and having an ongoing
counter which is divided by 26 when it goes past Z to work out
location. However, I'd dearly like there to be an easier way. Any
ideas?
Another problem I'm...
|
by: setterst |
last post by:
I am quite new to VBA and Access, but I am trying to figure out how to
export specific values from a table in Access, so I can save it in a
given cell in Excel. I have been able to figure out how to open and
modify cells in my spreadsheet, but I don't understand how to select
elements of the Access table to export it to Excel. Here is what I
have so far:
Dim xlApp As Object
Dim wkbk As Object
Dim Sheet As Object, Cell As Object
|
by: Kevin Humphreys |
last post by:
Hi There,
I am trying to export a recordset to an excel file using the Content Type
below in the header.
Response.ContentType = "application/vnd.ms-excel"
Which works fine however the problem is that when I have a number in a
column with a leading zero the zero gets dropped.
|
by: bobh |
last post by:
Hi All,
In Access97 I have a table that's greater than 65k records and I'm
looking for a VBA way to export the records to Excel.
Anyone have vba code to export from access to excel and have the code
use multiple excel tabs within a workbook????
Anyone have vba code that would create a temp table write 65,000
records to it, export those to excel, clean the temp table, append the
next 65,000 records, export it to excel with a different...
| |
by: semijoyful |
last post by:
OS: Win XP SP2
Access version: 2003
Excel version: 2003
I am new at this, as I am sure you have gathered from this post title:)
I am working on a form where users can input data in Access and at the end of the day be able to press a button on the form that would update that data to a single exel spreadsheet. The following is the code for the module. When I click on the button in the form, It takes me to VBS Debugger. I then type...
|
by: QCLee |
last post by:
Sir can you help me to transfer my Access Query to MS excel? i have a
command button on the form to export the parameter query named
"HVACWindwardQuery" to excel spreadsheet and i got the codes from
searching on the internet and books but the problem is when i run the
command button "Export" it just only open the Blank Spreadsheet, no
data at all that it came from my query named "HVACWindwardQuery" and
there's an error on it...
|
by: LoanB |
last post by:
Hi Guys
I am writing an application where by I need to export data from a data table (already populated with data from SQL Server).
I have never done this before so not sure where to start. Assuming I already have a connection to a spreadsheet called Orders.xls.
What code do I need to take data from the data table and insert it into a specific cell in the spreadsheet?
E.g.
|
by: jkwok |
last post by:
Hi,
I have a spreadsheet which I've imported into one table, 'Assets', in Access. In the table, I have to separate the data based on one attribute: 'empID'. empID is the employee ID and can occur in multiple rows, so it's not the primary key.
What I need to do is this:
1. go through the entire Assets table and produce a spreadsheet for each empID. So for each unique empID, a spreadsheet will be made containing all the data related in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |