Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 16-05-2009
Join Date: Jan 2009
Posts: 92
How do i transfer html form data to excel

I'm having many html forms, on which i had saved some personal data on it. Now, i would like to transfer that data on my Excel sheet. Can any body provide me the correct solution for the above issue? Have any body transfer their Html forms data to Excel sheet? Kindly provide me the solution for teh above issue.
Reply With Quote
Old 16-05-2009
Join Date: Apr 2008
Posts: 1,948
Re: How do i transfer html form data to excel

Hey you can try the following code in order to transfer your Html form data to Excel sheet.

DataSet ds=objAdmin.getErrorsInDetail();
Response.AppendHeader("Content-Disposition", "attachment; filename=Error.xls") ;

for(int i=0;i<ds.Tables[0].Columns.Count;i++)
Response.Write("<td>"+ ds.Tables[0].Columns[i].ColumnName +"</td>");
for(int i=0;i<ds.Tables[0].Rows.Count;i++)
DataRow row=ds.Tables[0].Rows[i];
for(int j=0;j<ds.Tables[0].Columns.Count;j++)

Response.Write("<td>"+ row[j]+"</td>");
Reply With Quote
Old 16-05-2009
Join Date: May 2008
Posts: 2,008
Re: How do i transfer html form data to excel

The XML file that is generated can be opened directly in Excel. For illustration purposes, the DataSet object is created from the Microsoft Access Northwind sample database by using the Jet OLEDB Provider. However, similar code works with any DataSet object that you create with Visual C# 2005 or Visual C# .NET.

1. Start Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET. On the File menu, click New and then click Project. Select Windows Application from the Visual C# Projects types. Form1 is created by default.
2. On the View menu, select Toolbox to display the Toolbox and add a button to Form1.
3. Double-click Button1. The code window for the Form appears.
4. Add the following using directives to the top of Form1.cs:
using System.Data.OleDb;
using System.Xml;
5. Add the following private member variable to the Form1 class:
private string strConn ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ " C:\\Program Files\\Microsoft Office\\Office10\\Samples\\"
+ "Northwind.mdb;";
Note You may need to modify the path to Northwind.mdb in the connection string to match your installation.

6. Add the following code to the button1_Click handler:

//Connect to the data source.
OleDbConnection objConn = new OleDbConnection (strConn);

//Fill a dataset with records from the Customers table.
OleDbCommand objCmd = new OleDbCommand(
"Select CustomerID, CompanyName, ContactName, "
+ "Country, Phone from Customers", objConn);
OleDbDataAdapter objAdapter = new OleDbDataAdapter();
objAdapter.SelectCommand = objCmd;
DataSet objDataset = new DataSet();

//Create the FileStream to write with.
System.IO.FileStream fs = new System.IO.FileStream(
"C:\\Customers.xml", System.IO.FileMode.Create);
//Create an XmlTextWriter for the FileStream.
System.Xml.XmlTextWriter xtw = new System.Xml.XmlTextWriter(
fs, System.Text.Encoding.Unicode);
//Add processing instructions to the beginning of the XML file, one
//of which indicates a style sheet.
xtw.WriteProcessingInstruction("xml", "version='1.0'");
// "type='text/xsl' href='customers.xsl'");

//Write the XML from the dataset to the file.

//Close the database connection.
catch (System.Exception ex)
Note You must change the code in Visual Studio 2005. By default, Visual C# adds one form to the project when you create a Windows Forms project. The form is named Form1. The two files that represent the form are named Form1.cs and Form1.designer.cs. You write the code in Form1.cs. The Form1.designer.cs file is where the Windows Forms Designer writes the code that implements all the actions that you performed by dragging and dropping controls from the Toolbox.

7. Press F5 to build and run the program.
8. Click Button1 to create the XML file, then close Form1 to end the program.
9. Start Excel 2002 or Excel 2003 and open the C:\Customers.xml output file.
10. After you have observed how the XML has been parsed into rows and columns in the new workbook, close the file and quit Excel.
Reply With Quote

  TechArena Community > Software > Software Development
Tags: , , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "How do i transfer html form data to excel"
Thread Thread Starter Forum Replies Last Post
Google Chrome is opening in basic HTML form instead of the Standard form Beatrix Technology & Internet 5 25-05-2011 10:21 PM
transfer data Between excel sheets kvirmani MS Office Support 1 21-04-2011 05:34 PM
Transfer data between sheets in excel Shanbaag Windows Software 3 16-10-2009 10:40 AM
Convert Excel data to HTML Table Chalina Software Development 2 04-08-2009 11:21 PM
Insertion of clean Excel data into oracle table using html Valerian Software Development 3 13-06-2009 09:34 PM

All times are GMT +5.5. The time now is 02:12 PM.