I would like to create a web application in.NET for someone to fill in a.CSV spreadsheet.
Currently, my web app takes a name, email and a password and it creates a spreadsheet with the name on the first column and an email on the second. When the user fills in their details, they click the add button and the spreadsheet is then saved and emailed to them.
I'd like to be able to fill in a spreadsheet with my web app, but I have no idea how I would do this.
Could someone give me some pointers?
Check out OleDb.
You will need the connection string in the spreadsheet file that you want to read/write from/to.
The OleDb Connection String
using (OleDbConnection conn = new OleDbConnection(ConnectionString))
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [Sheet1$]", conn);
// define the data reader
OleDbDataReader reader = cmd.ExecuteReader();
// define the data row
DataRow dr = new DataRow();
// create columns in the new row
dr["Column1"] = "col 1 value";
dr["Column2"] = "col 2 value";
// if there is data to read, add it to the table
// update the data row
dr["Column3"] = "col 3 value";
// add the row to the table
DataTable dt = new DataTable();
Documentation on OleDb.
You can also use ADO.NET to read/write the spreadsheet.
You'll need to load the spreadsheet and store it somewhere (probably a database) to 0b46394aab