473,320 Members | 1,814 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,320 software developers and data experts.

Export data to Excel

Hello
I am exporting data to Excel from my .net Application using ISAM(Jet). I
want to delete all record in the sheet before exporting. Since ISAM does not
support Delete Operation. I am trying to Delete the Sheet and then create new
sheet. The code executes successfully but The when i open the sheet it
contains the existing data.
for(i = 0;i<SchemaTable.Rows.Count;i++)
{//if schema is there then searches for the specific sheet
if(SchemaTable.Rows[i]["TABLE_NAME"].ToString()==sheetName)
{
OleDbCommand ol1= new OleDbCommand("DROP TABLE " +
sheetName.Substring(0,sheetName.Length-1),conn);
ol1.ExecuteNonQuery();
break;
}
}
try
{
OleDbCommand ol = new OleDbCommand("create table [" +
sheetName.Substring(0,sheetName.Length-1) + "] (" + getExcelColumnNames(true)
+")",conn);
ol.ExecuteNonQuery();
}
catch(Exception e)

MessageBox.Show(e.Message,TitleText,MessageBoxButt ons.OK,MessageBoxIcon.Information);
return false;
}
}
Jul 21 '05 #1
1 1472
On Thu, 10 Mar 2005 00:43:04 -0800, "Abhijeet Kumar" <Ab***********@discussions.microsoft.com>
wrote:

¤ Hello
¤ I am exporting data to Excel from my .net Application using ISAM(Jet). I
¤ want to delete all record in the sheet before exporting. Since ISAM does not
¤ support Delete Operation. I am trying to Delete the Sheet and then create new
¤ sheet. The code executes successfully but The when i open the sheet it
¤ contains the existing data.
¤
¤
¤ for(i = 0;i<SchemaTable.Rows.Count;i++)
¤ {//if schema is there then searches for the specific sheet
¤ if(SchemaTable.Rows[i]["TABLE_NAME"].ToString()==sheetName)
¤ {
¤ OleDbCommand ol1= new OleDbCommand("DROP TABLE " +
¤ sheetName.Substring(0,sheetName.Length-1),conn);
¤ ol1.ExecuteNonQuery();
¤ break;
¤ }
¤ }
¤ try
¤ {
¤ OleDbCommand ol = new OleDbCommand("create table [" +
¤ sheetName.Substring(0,sheetName.Length-1) + "] (" + getExcelColumnNames(true)
¤ +")",conn);
¤ ol.ExecuteNonQuery();
¤ }
¤ catch(Exception e)
¤ {
¤ MessageBox.Show(e.Message,TitleText,MessageBoxButt ons.OK,MessageBoxIcon.Information);
¤ return false;
¤ }
¤ }
You can't use data access methods to delete (or DROP) a Worksheet in a Workbook. The only method
that works is Excel automation.
Paul
~~~~
Microsoft MVP (Visual Basic)
Jul 21 '05 #2

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....
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...
4
by: Jiro Hidaka | last post by:
Hello, I would like to know of a fast way to export data source data into an Excel sheet. I found a way from C# Corner(Query Tool to Excel using C# and .NET) which is a neat little way of...
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"...
1
by: JawzX01 | last post by:
Hello All, First, thank you for any help you can provide. I'm trying to do a simple export to excel. I've used the classic code that is all over the internet, and of course it worked without a...
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...
7
Merlin1857
by: Merlin1857 | last post by:
Its great producing data for users to look at in your web pages and generally that is sufficient for their needs but sometimes you may want to supply your user with the data in a form they can...
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
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: 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)...
0
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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.