Do you know any external MS Excel library for C# (it should work without MS Office installed on machine) which has possibility to run macros?
It's possible to run it with "Microsoft.Office.Interop.Excel", but for that you need MS Office.
The scenario: I have MS Excel file template with macro. Adding part of the data programmatically to that template, running macro which was wrote to excel template, adding another part of data.
Thanks in advance!
NPOI is a great tool and is Open Source:
NPOI
Related
I have to make a simple WPF application that manages and displays some data in form of objects(strings and ints). It needs to be saved in excel format, so that it can me manually opened and viewed by any user with Excel. But because not every user necessarily has Excel it needs to be independent from it. I found very few solutions but none worked for me. This works but as far as I know it needs Excel installed to run.
I use EPPlus for this purpose. http://epplus.codeplex.com/
It does not require that you have excel installed and is easy to use.
You can't use Microsoft.Office.Interop.Excel without having Microsoft Office installed.
You can use external libraries that allow xls or xlsx modification without Excel installed:
http://code.google.com/p/excellibrary/
http://simpleooxml.codeplex.com/ (only xlsx)
I have an Excel template 97-2003 (xls) which contains some VBA macros, format/formula and style and I put it on my web application (ASP.Net MVC, c#) and I'm stuck in writing function 'export data filled in this Excel template without using COM, result format must be *.xls'. And I need to update the VBA macros programmatically tool. I've tried Excellibrary https://code.google.com/p/excellibrary/ but it only save as the cells content. And EPPlus library don't work for xls.
Going with COM interface for MS Excel is the easiest option to write XLS (but please notice that Microsoft is not recommending to use Office components in server-side apps due to some technical and licensing considerations.)
There are couple of 3rd party commercial .NET (with .NET interface) components which are capable of reading and writing XLS:
Gembox.Spreadsheet
Aspose.Cells
Infragistics Excel
Spreadsheet Gear
ByteScout Spreadsheet SDK
Disclosure: I am affiliated with ByteScout
I have developed an Excel add-in application with a User Defined Function (UDF) in c#. I have created an installer .vsto file using the setup wizard. It's working fine and my ribbon gets loaded in Excel.
The problem is that when I try to insert a UDF function in my worksheet, the function is not visible in my function wizard or does not load.
Why is this happening and what can I do to solve this?
VSTO IS NOT DESIGNED TO SUPPORT UDFs, if you really need to have UDFs for Excel written in C# (or .NET generally), you have some solutions to choose from, includes, but not limited to:
Automation (COM) Add-ins: here is a good article about this.
Excel DNA: a free and open source project, available at:
http://excel-dna.net/
Addin Express: Which is a commercial product:
http://www.add-in-express.com/docs/net-excel-udf-tips.php
Finally, a good Code Project article to read about UDFs.
I'm currently developing application using WinRT/C#. It is second version, first was developed on WPF. In application I need to generate some reports and export them into MS Word document.
In first version of application I used MS Office Interop to export reports in MS Word, but in WinRT there is no support of MS Office Interop. Is there any simple way to create MS Word document in WinRT? (I know there are third party libraries like Syncfusion for WinRT but I would prefer to not use them).
You won't be able to use MS Office interop from a Windows Store app. You could use Open XML SDK, though. It is also available on NuGet and seems to be WinRT compatible.
Using it won't be as easy as working with interop classes and you'll only be able to create XML based docx files, not binary doc files. On the other hand your users won't need to have Word installed and they'll be able to open the files in other Office suites like OpenOffice or LibreOffice. There's a set of tutorials available on MSDN to get you started.
There is a free solution that consiste to format your document in rtf.
For this i create a new librairy to help a developper to create a document compatible with word.
you can find this there : https://github.com/crogun/WinRTF-For-WinRT
the code is open source, and you can extend it if you want.
Can I create an Excel sheet using the C# without having MS Office installed on the host machine?
If you are targetting Office 2007+ - you can take a look at the the Office Open XML. Your .xlsm is basically a compressed XML file and as long as you are not doing anything fancy - it should be easy to generate.
If however - you are targeting Office 2003 or earlier - the .xls is a binary format. You might need to look at abiword or star office to see if you can use any of their code to serialize you data to it.
I have achieved this using the EPPlus library.
In the past I've created a simple HTML table and saved as .xls and this has opened fine in Excel.