0

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

2 Answers 2

2

You need to add readonly= false to your connection string, see:

Writing into excel file with OLEDB

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. I am getting following Exception at: conn.open(); Exception is: "Could not find installable ISAM." Please help
0

SpreadsheetGear for .NET will let you open, modify and save Excel workbooks, has no limits on the structure of a workbook, and does not rely on OLEDB or anything else (other than .NET 2.0+).

You can see live samples here and download the free trial here if you want to try it yourself.

Disclaimer: I own SpreadsheetGear LLC

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.