Last post Dec 16, 2014 04:19 PM by Mikesdotnetting
Dec 15, 2014 03:47 PM|bbcompent1|LINK
Hey everyone, I am trying to figure out how to use OleDB to build an excel file from several others. I know I could use office Interop but this is generally a bad choice for servers so has anyone done this before and if so, do you have any code to show?
Dec 15, 2014 05:36 PM|Mikesdotnetting|LINK
You can query the contents of the other files and add them to some kind of collection or dataset, then insert that into the file you want to create.
Dec 16, 2014 01:58 PM|bbcompent1|LINK
Hey Mike, do you have an example of the code that would write to the excel? I can handle the reading part, its writing with OleDB to an Excel file that is escaping me.
Dec 16, 2014 04:19 PM|Mikesdotnetting|LINK
It's a straightforward SQL INSERT INTO statement. The table name is the name of the sheet. You just need to ensure that the account which your app executes under has WRITE access to the folder containing the Excel worksheet you want to write to. There's
an example in this article: http://www.mikesdotnetting.com/article/207/exporting-the-razor-webgrid-to-excel-using-oledb