C# Excel Interop - Cell text cut off on publishing - c#

I have an Excel sheet where the text overflows the cell and into the next one, but when using the C# Excel Interop to publish this worksheet the text is simply cut off where the cell ends. If I publish the same worksheet from the Excel application the text is not cut.
I don't want to use wrapping as I'd like the resulting PDF to remain as close to the original Excel sheet as possible. How can I prevent the text from being cut off?

Related

C# EPPlus cannot Read Excel Spreadsheet

I am trying to read the data in an .xlsx workbook.
EPPlus is successfully reading the Workbook without any errors. The problem is the Worksheets inside the workbook.
EPPlus seems to not read the worksheets. See screenshot below.
enter image description here
I opened the Workbook that I want to read and found out that all the Cell formats are in "Custom".
enter image description here
I tried to change the cell formats manually to "General" and EPPlus successfully reads the Worksheets.
enter image description here
The thing is that the excel file is coming from a downloaded file via Selenium UI automation. And since this is an automation, I do not want to have a manual intervention wherein I will have to change the cell format to "General" every time I run my auto scripts.
Do you guys know any workarounds / other libraries that can read excel worksheets with cell format as "Custom"?
BTW, I am using EPPlus version 4.5.3.3

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 create an embedded Excel worksheet in a Word document and populate it with data?

Say I have a word document and a Excel worksheet, how can I create an embedded Excel worksheet within the Word document, which you can manipulate just like a normal Excel sheet.
Then, after creating it, how do I populate it with the data from the original Excel worksheet?
Edit: I should have clarified that this should be done programatically in C#.
Go to intsert->Object->create new, select Microsoft excel and click ok.
It will insert a blank excel in your word doc.
To edit the excel inserted in word doc, right click, worksheet object-->edit
Then simply copy the values from any other excel and paste it here.

Need to convert Excel sheets into Text (tab delimited ) as in MS Excel 2007 programatically using C#

Ok, here is the problem
MS Excel allows me to save the whole sheet as text tab delimited
I'm using this text in a program , but the user needs to make the previous step manually
I want to automate this step so the user only import the Excel Book into my program , and shows how many sheets inside it letting the user select the desired sheet and then the program will convert this sheet into text (tab delimited ) , any ideas ?
Well... one of the easiest to learn methods would be the use Excel Interop. The downside of this method is it (1.) requires Excel to be installed and (2.) Can get messy very quickly... but generally it makes sense.
I suggest familiarizing yourself with Excel Interop. Now, take note of the SaveAs method for the Workbook object.
Loop through the Worksheets property of the opened Workbook.
Display the sheet names for the user to choose.
Get the desired sheet by name and access the Worksheet object
Use the desired Worksheet's Select method
Use the Workbook's SaveAs method. Be sure to use FileFormat option to make it tab delimited.
Hope that helps. Just remember, it's doable.
There are several options:
OpenXML 2.0 from MS - http://msdn.microsoft.com/en-us/library/bb448854.aspx...
It is a free library that does NOT require office to be installed... you can read + write Office files including Excel and Word (Version 2007 and up...).
VSTO/Office Interop from MS - http://msdn.microsoft.com/en-US/office/hh128771.aspx
this need Office to be installed and works only in desktop apps (NOT services or ASP.NET..) and let's you automate whatever you want...

Categories

Resources