Load existing excel file to edit in C# - c#

I want to load an existing macro enabled Excel file to edit in C#. When I say existing Excel file, I mean that I want to set a template that the user must start with.
I am stuck at the first step, loading the Excel file. I managed to add the file to the solution, so it pops up in solution explorer but I don't know how to edit it in C#.

Related

EPPlus Excel Exporting hides some tabs

I am using C# with EPPlus library.
The task is that I am opening an excel file, removing some sheets from it and saving it as a separate excel file.
The issue I am facing is that the excel sheet tabs at the bottom are moved out of view in the output file saved:
The activesheet is sheet 1, but the Sheet 1 tab is not visible on the excel file.
Is there any command using EPPlus which can amend this to look like:
Files saved by Excel can contain information about the width of the tab area. I am quite sure that EPPlus does not take care of this detail.
If you rename a .xlsx file to .zip and take the xl\workbook.xml file of it you will find a section that may contain an attribute 'tabRatio'. The attribute is present only if the width is adjusted manually. This attribute or the whole section may be deleted.
I did a test: I saved a file with too little space for the tabs and after deletion of the section the tab area looked fine again.
Maybe EPPlus generates the 'tabRatio' attribute but with useless values? Please check for it. If so, you might want to file a request for the developers to leave it out if it does not make sense.

Loading spreadsheet template file doesn't retain form button

I am using SpreadsheetGear 2012 in my application to load, modify then save a new copy of a template workbook.
My code takes invoicing information from a database and formats it for the workbook. Then the user will print an invoice from the formatted information using a button on the workbook.
I use a template workbook with some formatting already provided to make my life easier. Included on the original template workbook is a button that runs a VBA macro in the spreadsheet. The VBA macro loads successfully but the button just disappears in the new workbook.
Some of the steps I have tried to rectify the issue: I've added a new button, changed the VBA macro code from a function to a sub, saved the template file as a macro-enabled spreadsheet (.xlsm) and saved the revised copy as a macro-enabled spreadsheet file.
Has anyone experienced this issue and do you have a solution?
If you are using the Open XML file formats (XLSX/XLSM), then this is a known limitation:
http://www.spreadsheetgear.com/support/help/spreadsheetgear.net.7.0/#SpreadsheetGear_2012_Limitations.html
In short, SpreadsheetGear 2012 does not support reading/writing Form Controls (like buttons), as well as Cell Comments, when working with the Open XML file formats. So your button is getting dropped when the file is initially read into SpreadsheetGear.
If you want to preserve these objects through SpreadsheetGear, you will need to use the XLS (FileFormat.Excel8) file format, which does support them.

How to embedded Excel file in ASP.Net page?

How to view excel file in ASP.Net page using c#?
I need to view excel file in asp.net form and access the all excel functionality in this excel sheet.
Note:
Excel sheet will open inside the form tag, it means open within a page, not open separate file.
Like: Update fields, Merge fields, Wrap cells, Format the fields and apply text color. whatever Excel sheet have functionality all will be work asp.net excel page.
Thanks in Advance.
You can upload this file to Google Doc and open it then chose File -> Publish to the Web -> Get html code and paste them.
Good luck.

Creating excel - improve performance

Good afternoon,
we have a small problem with performance of generating excel.
First, we was creating excel cell by cell - it is ... let's say unacceptable.
Second, we started insert into excel with one command - range creating and it is much faster, but still not perfect so we are searching next solutions.
Because we can load XML file from database, we tried used XSLT and from these two files create xls file. It is nice, but after open this file there is error message shown (it is because of problem or bug in registry). User has to accept this message and after excel is opened. We want to eliminate this error message. However we don't know how.
We was thinking about convert this xls file into xlsx but we are unable to do it becouse we can't install office on server (we cannot use Interop) and OpenXML libraries don't know work with normal xls file. So my question is:
Is possible to generate from XML file with using of some XLST (or something) the xlsx file?
Eventually can what files do we need to create and zip together if we want create xlsx file?
Thank you for information
You mention not being able to use the OpenXML libraries because they don't work with .xls files, but you also say "creating cell by cell", which implies that you are generating the file from scratch. Where is the xls file coming from? You mention excel opening, but then say you can't install it on the server. So, it appears to me that a user is uploading an xls file to your server, and then you are doing something with it and giving it back to them? If that is the case and you must be able to read/write an xls file without installing office, then I would suggest using ExcelLibrary, as mentioned in this post
Indeed, creating an xlsx file is much magnitudes faster with the open xml sdk.

Excel 2003 bug at the 1st launch after creating file from c#

I am creating a new .xls file for the Microsoft Office 2003 from existing template in C# using .NET 4.0 and Excel Interop Object Library. My template already contains all needed data and various formulas so my task is just to change some cells which are used in formulas as parameters. I do this without any problem...
The problem appears when i try to open my new file: when the file is opened at 1st time addins of excel doesnt work and as the result all the formulas show me error messages like "#NAME". When i launch the file again - everything is ok...
This makes me angry....
Does anybody know where the problem could be? And what is the solution??
Thank you in advance.
Do you open it Excel 2010? If so, then Excel thinks it's with macros and displays it incorrectly.
Basically, #Name error appears when the formula inside the cell can't be interpreted or is unknown.
The problem is related to the path of formulas, I guess in the first launch it can't correctly find the formulas path so in the next launches it shows them correctly.

Categories

Resources