How to create and update spreadsheet using OLEDB in C#?
Posted
by vamshi
on Stack Overflow
See other posts from Stack Overflow
or by vamshi
Published on 2010-03-15T12:13:54Z
Indexed on
2010/03/15
12:19 UTC
Read the original article
Hit count: 260
HI! all I am creating .xls spreadsheet file using following code
using (OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\temp.xls;Extended Properties='Excel 8.0;HDR=Yes'"))
{
conn.Open();
OleDbCommand cmd = new OleDbCommand("CREATE TABLE [NewSheet] ([Column1] string, [Column2] string)", conn);
cmd.ExecuteNonQuery();
}
but i am getting an exception at cmd.ExecuteNonQuery();
Exception is: Cannot modify the design of table 'NewSheet'. It is in a read-only database.
Please help me to resolve this
Thank You
© Stack Overflow or respective owner