OPEN XML to Export 2007/2010 - c#

In my application I already have functionality to export into 2003 format. Where I am constructing a string out of the template and write using System.IO.File.WriteAllText.
But it does not work with excel 2007/2010, that's why I wanted to convert it to Openxml in order to support 2007 and 2010.
I have string ready with creation of cells and rows from template.
I want advice on how to achieve or any body has reference link.
Please let me know.
Regards

WriteAllText class will save you a text file. You are saving an html(text) based file with xls extension. This is not a real xls file (that is actually a binary file), but MS Excel recognize and interpret the html format.
An xlsx file is a binary file. You can use OpenXML Office library ( Excel.XlFileFormat.xlOpenXMLWorkbook ) or another .NET Excel library like EasyXLS. Check this sample of code for more details.

Related

openxml or closedxml work with xlsb file using c#

I am unable to write data to Excel binary ".xlsb" file using openxml with c#
i want to use it for writing data to binary "xlsb" file using c# but without excel interpro.
i tried openxml but it is not working.
Unfortunately Open XML SDK cannot handle .xlsb files since they are stored as binary. The Office XML Formats which Open XML SDK could recognize are based on XML and ZIP technologies, rather than binary. Generally Open XML SDK could handle spreadsheets like ".xlsx", "xlsm", "xltx" and so on.
i found it in https://social.msdn.microsoft.com/Forums/office/en-US/bf78ca1d-50dd-4690-8bc6-fbcdecacddb3/handle-xlsb-files?forum=oxmlsdk

How to convert Excel to Html using OpenXml

Currently, I can convert Word to Html using OpenXml with ConvertToHtml method. But I can not apply this method for SpeardSheetDocument file (xlxs). So how can I similarly convert the excel file to Html via OpenXml. Or is there any other approach for my situation ? It would be better if I can convert powerpoint file (ppt) to Html too.
I know there is a library called Interop but if I use this I need to install microsoft office, but I dont want to install those softwares.
Thank all !

Save as pdf using ClosedXML

Does ClosedXML have any function that can be used to save an excel file as PDF?
Currently i am using ClosedXML to create and populate the excel file and then using Interop to save as PDF.
But since Interop depends on the MS Office installed on the syatem the formatting changes on every version of MS Office. And since ClosedXML doesnt require having MS office installed it would be nice to be able to export or save as PDF directly from it without using Interops.
Does ClosedXML have any function that can be used to save an excel file as PDF?
No.
Instead you can use the free version of GemBox.Spreadsheet.
Also look at the top 10 libraries which allows us to manipulate excel.
However GemBox was the only free and featured one that I found with the purpose of creating an invoice report for a website, by converting excel to pdf.
you can use the ClosedXML.Excel and iTextSharp to convert Excel to PDF file.
Here a link with example:
Convert Excel file to Pdf in ASP.Net

Making a pdf copy of a csv file programmatically in C#

I have a csv file and I need to make a pdf copy in the console application that creates the csv. All I have found 3rd party libraries for working with pdf but I don't want to use that. Can I just make a copy and save it as a pdf? If so, how?
Also, I'm using C#, in case you didn't read the title.
Try the below link hope it will help you.
http://sourceforge.net/project/platformdownload.php?group_id=72954
You can open the csv with excel.
than use office PIA (interop) to save as PDF.
see:
Can I use Microsoft Office 2010: Primary Interop Assemblies to convert word,excel to PDF
first read the csv files using c# code, and load that data's into DataTable,
write the datatable values into pdf file using c#
may this idea will help 4 u

Excel to XML in .NET3.5

How to convert Excel file to xml file using .NET framework 3.5
Please tell the approaches
The format of excel sheet is xls and convert to standard xml format
SpreadsheetGear for .NET will let you open a workbook (xls or xlsx format), get the formatted text (such as $5.00) with the IRange.Text property or the unformatted raw value with the IRange.Value property. You can also modify values and recalculate if needed. You would need to use the .NET XML APIs to write out the formatted text or unformatted values to an XML file.
You can download a free trial here if you want to try it yourself.
Disclaimer: I own SpreadsheetGear LLC
You can do it in various ways based on your requirement
You can read it like a database using OleDbConnection object to connect to the file and read data
You can use System.IO.Packaging to read office 2007 (xlsx) files
You can also use Excel.Application object model to read information from Excel
It really depends on your requirement what method is effective for you.

Categories

Resources