开发者

External table is not in the expected format in excel through C#

I trying to copy the one excel sheet to another excel sheet. I have a excel file and in it there is a sheet. Now I want to create a new excel file which should have the another sheet with the data which is in the earlier sheet as well as some updated data also.

For this I am reading the whole data from first excel sheet and storing in some DataTable, whi开发者_C百科ch is working fine.

But now when I am creating a excel sheet through StreamWriter and trying to open that connection for inserting the records it is giving me this error.

"External table is not in the expected format in excel "

System.IO.StreamWriter oExcelWriter = System.IO.File.CreateText(@"filename.xls");

conn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=file.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=0"";";

why it is giving this error. I don't want to use Interop, I want to use OleDb only.


You can always use an empty excel file as a template and then instead of creating new file, make a copy of template and open it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜