473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Export To Excel

Is there a way to export data from a control into excel if the control
is not server side? Do I have to do it with java script or can I do
it inside my VB.NET code?

Feb 9 '07 #1
16 2218
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
Is there a way to export data from a control into excel if the control
is not server side?
Difficult to say without knowing what control it is... You say it's not a
server-side control, so is it an ActiveX control or a Java applet...?
Do I have to do it with java script or can I do it inside my VB.NET code?
See above.
Feb 9 '07 #2
Difficult to say without knowing what control it is... You say it's not a
server-side control, so is it an ActiveX control or a Java applet...?
It's a control built inside the HTML of the page but it does not have
the runat="server" tag in it. So I don't have a way to access it in
VB.NET.

I'm relatively new to ASP.NET (some training) so am not real sure the
best approach at grabbing this control and it's data.

Here is a sample of what the first part of the control's code looks
like in the HTML. I don't have any way that I can see to grab this
"DataTable" control (and it's data) inside VB.NET:

<table id="DataTable" dataSrc="#ReportResult" cellSpacing="0"
cellPadding="1" border="1">
<THEAD>
<TR>
<td class="COLHDR2" onclick="SortFields('@SomeDBParameter')"
width="65">SomeDBValue</td>
<td class="COLHDR2" width="70"
onclick="SortFields('@AnotherDBParameter')">Anothe rDBValue</td>

Feb 9 '07 #3
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
>Difficult to say without knowing what control it is... You say it's not a
server-side control, so is it an ActiveX control or a Java applet...?

It's a control built inside the HTML of the page but it does not have
the runat="server" tag in it.
So what is it, then...???? Where does it come from? What builds it? Where
does it get its data from...?
<table id="DataTable" dataSrc="#ReportResult" cellSpacing="0"
cellPadding="1" border="1">
<THEAD>
<TR>
<td class="COLHDR2" onclick="SortFields('@SomeDBParameter')"
width="65">SomeDBValue</td>
<td class="COLHDR2" width="70"
onclick="SortFields('@AnotherDBParameter')">Anothe rDBValue</td>
Wow! It's been a while since I've seen anything like that! Is this even
ASP.NET...?
http://msdn.microsoft.com/library/de...es/datasrc.asp

OK, so what is populating the table's dataSrc property...?
Feb 9 '07 #4
You'll have to bear with me. I'm new to ASP.NET and new to this app.
So what is it, then...????
It is a control that is built inside HTML. I'm not sure what else to
say to answer that question.
Where does it come from?
The control? It comes from the HTML side of this page (am I still not
getting the question)?
What builds it?
Again, isn't the HTML inside the page building this control?
Where does it get its data from...?
The data is grabbed from the database and dumped into a dataset. Then
the xml from that dataset is put into a HtmlGenericControl object.
However, once I have left the method that does this and do anything
else, that HtmlGenericControl object is empty. So I can't figure out
how to get my hands on the data.
Is this even ASP.NET
Yep
OK, so what is populating the table's dataSrc property...?
Same answer as the data question above (I believe anyways)

Feb 9 '07 #5
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@v33g2000cwv.googlegr oups.com...
>Where does it get its data from...?
The data is grabbed from the database and dumped into a dataset. Then
the xml from that dataset is put into a HtmlGenericControl object.
Aha - now we're getting somewhere! OK, so you do have access to the
underlying data... So how precisely do you want to export it to Excel...?
You have a few possibilities here... Do you want to display the data in
Excel in a browser window, create a CSV file which the user can download and
display in Excel etc.

What is the purpose of exporting the data to Excel anyway...? Is the user
going to process it in some way...?
Feb 9 '07 #6
So how precisely do you want to export it to Excel...?

I'd like to create it in a csv file.
What is the purpose of exporting the data to Excel anyway...? Is the user
going to process it in some way...?
the user would like to save the data off and process it at a later
time.

Feb 9 '07 #7
So now that we know what I want to do, does anyone know how I can do
it? How do I get ahold of a control that is built in HTML and not set
as server side and do so inside the VB.NET code?

Feb 10 '07 #8
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@s48g2000cws.googlegr oups.com...
So now that we know what I want to do, does anyone know how I can do
it? How do I get ahold of a control that is built in HTML and not set
as server side and do so inside the VB.NET code?
Apologies - I thought you'd got it...

You don't need to "get ahold" of this control at all, as you already have
the data anyway (i.e. the dataset).

All you need to do is add another button to your page which takes the
dataset and does the export. There are tons of examples of the various ways
you can do this:
http://www.google.co.uk/search?sourc...t+export+Excel
Feb 10 '07 #9
Hi Mark, I was kind of figuring that would be an option of mine, to
use the dataset originally returned and can do that easily enough.
However, woudln't there be a performance hit of some kind if I'm
storing the data in a control on the page, and I'm storing the same
data in a dataset in memory? By the way, thank you for your continued
help here. :)
Feb 10 '07 #10
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@l53g2000cwa.googlegr oups.com...
Hi Mark, I was kind of figuring that would be an option of mine, to
use the dataset originally returned and can do that easily enough.
Sorted, then...?
However, woudln't there be a performance hit of some kind if I'm
storing the data in a control on the page, and I'm storing the same
data in a dataset in memory?
Only, I suppose, if every user always wants to export the data to Excel
every single time they access the page... If that's the case, then there
hardly seems any point in actually displaying the data in the first place...
Feb 10 '07 #11
This seems like a dumb question but I'm going to ask anyways. In
VB.NET (or ASP.NET) if you have a class level variable and you set it
to a value, is there some reason that variable does not retain its
value? I created a class level dataset, dumped the results of my
search into it, walked through it and everything is fine. But the
moment I get out of the method that does the search and do anything
else, that class level variable does not contain any data??????

Does ASP.NET wipe variables - even class level ones for some reason?

Feb 12 '07 #12
"Doogie" <dn******@dtgnet.comwrote in message
news:11**********************@j27g2000cwj.googlegr oups.com...
Does ASP.NET wipe variables - even class level ones for some reason?
Generally speaking, variables are (eventually) collected by the garbage
collecter when they go out of scope - please post your code...
Feb 12 '07 #13
Never mind, I forgot about the whole view state thing with ASP.NET
(It's really hard to switch from behind the scenes and windows
development to the web side. :) Or harder than I thought it would
be. :))

Feb 12 '07 #14
I do have one follow up question. I can get the data to excel just
fine now, I just use the EnableViewState property on the
HTMLGenericControl to keep my data handy. However, the problem I see
is that control has more data in it than is displayed on the form.
Several columns are in there that don't show up on the form.

I did some looking and the whole structure for what is displayed on
the form is built inside the HTML side of the page. Here's a short
version of what I'm looking at in my HTML.

<table id="DataTable" dataSrc="#ReportResult" cellSpacing="0"
cellPadding="1" border="1">
<THEAD>
<TR>
<td class="COLHDR" width="60">UpdateDt</td>
</TR>
</THEAD>
<tr>
<td nowrap><span datafld="UPDATE_DT"></span>&nbsp;</td>
</tr>
</table>

So now I'm not 100% sure how to set this up to display only the
columns that are defined in the HTML, without having to build some
sort of mapping structure. Is there another way?

Feb 12 '07 #15
Oh yeah, because I'm writing the data from this control and it's XML,
Excel always prompts me with the following. Is there a way to set
some setting so the user doesn't get this prompt each time?

"Please select how you would like to open this file:
As an xml list
As a read-only workbook
Use the xml source task pane"

I'd like to just have it open as an XML List but when I do then it
prompts me saying that the "specified XML source does not refer to a
schema" and "Excel will create a schema based on the xml source
data". I'd like to avoid those prompts too because I'm guessing the
user is not going to want to click those everytime.

Feb 12 '07 #16
Never mind, I finally got this to work the way I want. I went back to
using the DataTable (and storing that in the Cache object).

Feb 12 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table....
5
by: Maria L. | last post by:
Hi, I need to export the content of a DataGrid (in Windows application in C#), into an Excel spreadsheet. Anyone knows how to do this? Any code snippets would help! thanks a lot, Maria
2
by: Siu | last post by:
Hi, I use the following code to export and import a file Excel from resp. into a Web page with the following code: //EXPORT Response.Clear(); Response.Buffer = true; Response.ContentType =...
6
by: Elena | last post by:
I'm trying to export data to an Excel worksheet. I can export the data in the cell values perfectly. I need the code to change a header and footer for the worksheet, not for the columns. Is...
13
by: Hemant Sipahimalani | last post by:
The following piece of code is being used to export HTML to excel. HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"...
5
by: Simon | last post by:
Dear reader, With the export command you can export a query to Excel. By activate this command a form pop's up with the following text:
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
3
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.