We help IT Professionals succeed at work.

How to create .xlsx file in C# using Microsoft.ACE.OLEDB.12.0 without installing Microsoft Access Data Engine on the server?

How to create a .xlsx file in C#. I am using Microsoft.ACE.OLEDB.12.0. On my local machine it is working fine. When I deploy the same code to server, its not working. Microsoft.ACE.OLEDB.12.0 is not registered on the server. Issue is not to install anything on the server. Please let me know how to fix the below attached code, creating .xlsx file without installing any exe on the server. I can include .dll with the the code that fix this issue?
code.docx
Comment
Watch Question

John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:

If no installation is possible probably is better to create a .CSV file to feed to the users.

AndyAinscowFreelance programmer / Consultant
CERTIFIED EXPERT

Commented:

Simple.  Create the file on your PC then copy the file to the server.  No need to install anything on the server and you can create the file you need locally you have said.

Author

Commented:
I need to execute Sql server job on the server. Job uses a package. Package contains Script task written in c#. the script task reads data from sql server and store it in .xlsx file. I cannot change the file extension. File extension should be .xlsx
Freelance programmer / Consultant
CERTIFIED EXPERT
Commented:

If you MUST run it on the server then you need to install the drivers on the server.  (They are included in the freely availabe AccessDatabaseEngine.exe from microsoft).


If you can not install anything on the server then my first suggestion will work and do what you are asking for.

Author

Commented:
Any other way to create .xlsx file?
AndyAinscowFreelance programmer / Consultant
CERTIFIED EXPERT

Commented:

Can you install anything on the server?  (eg Microsoft Office)

John TsioumprisSoftware & Systems Engineer
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:

I don't know if this is of some help : https://github.com/JanKallman/EPPlus

It is supposed to create Excels (.xlsx) based on the fact that .xlsx is actually XML files.

Fabrice LambertConsulting
CERTIFIED EXPERT
Distinguished Expert 2017

Commented:

Without touching the server, beside a file transfer, nohing else.

Benjamin LuSAP/ERP Data Processing
CERTIFIED EXPERT

Commented:

For data integration, I would suggest you to use Pentaho Data Integration(PDI).

It can handle most of the data file format(inport/export,handling...).

Also, you can set up schedule job with command line in Schedule Task.

Chinmay PatelChief Technology Ninja
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:

Hi Sarad,


Please post your code using the Code tool. I do not think you need to do anything on the server with OleDB if you are only interested in generating an excel file.


I have some PAQ, I think you might want to look at them.


https://www.experts-exchange.com/questions/29125639/Writing-to-excel-via-Excel-Interop.html#a42730618


Please note that Microsoft Open XML SDK is the best solution if you are looking at a server based solution BUT it is pretty complex and can induce a severe headache if you need to perform fancy operations with the file.


Another advantage of Open XML SDK is it can generate anything from the ***X family i.e. DOCx, PPTx, XSLx and that too without having any interops on the server.


Also, you have an open question where I have already listed these libraries. Please have a look:

https://www.experts-exchange.com/questions/29172990/How-to-create-xlsx-file-in-c.html#a43032372


Regards,

Chinmay.