Assign RTF/HTML code to Excel cell - c#

I am Working on Microsoft C#.net(windows)
I have a requirement ,
I have an excel file containing formatted text in a cell (ex: text will be bold,italic,color) . I need to save the cell content in to the sql database.
Then i need to show the saved formatted text from database to a new excel file.
How to assign RTF code and HTML code to Excel cell.
Is there any option available. Please help
Thanks
Sandeep

i think you can use openxml to split the data along with cell formart and save in different tables in your db by referencing some id.
Lets say sheet 1 has sheetid as 1 and against this sheet id save data in your table and against same sheetid save cell number and style associated like font border fill.
Below Link can be helpful.
http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.cellformat.aspx
I am writing code for the same will share soon

Related

how to fill xlsx template whith dynamic data to generate chart by NPOI?

I have a .xlsx file which contain a chart as a report template. I create a table manually as the data source of the chart. What I want to do is to fill the table with data so that the chart I inserted will change respectively, the data is dynamic.
The problem I met is the same as the link below:
"The new row we just added wasn’t included in the table. The chart that is linked to the table won’t update because it isn’t aware of the new row".
(https://www.leniel.net/2009/10/npoi-with-excel-table-and-dynamic-chart.html)
image that show the problem
The solution in this website is to extend table manually in excel app.I have thousands of data row to insert so the solution is not suitable for me.
Is there any methods to extend table by code?

How to Set column Formats In Excel File from C# Code

I have a protected standard template excel sheet with formulas that I am loading SQL data to Excel through SSIS. While loading all int columns are convert to text format in an excel. Because of that formulas is not working until I double click each cell.
Or if I change that entire column format, right-click, select Format Cells and set the alignment or number format for the entire column, then it is calculating. I was wondering is there any way that I can change column format using C# code? or is there any better way to do this.
Right-click on the Excel Destination, and select "Show Advanced Editor". Change to the "Input and Output Properties" tab. Expand the "Excel Destination Input" and "External Columns". Click on the "Premium" column. The Data Type is probably "Unicode string [DT_WSTR]". Change it to an appropriate numeric type.

How to read the specific data from an excel and write them in different column of the same worksheet.using asp.net c#

enter image description here[I want to copy the data under the column 'Row Labels'(A6) and write them under the column 'Incident'(F2) by overwriting the previous data in the same excel sheet] Please help me out.

I am displaying the contents of an Excel file in a Gridview. How do I handle merged cells?

I want to read and display an excel file in a web page. I am using Microsoft.Office.Interop.Excel in .aspx.cs and GridView in .aspx. I am just reading it into a DataTable and binding it to GridView.
The problem with this is, I can't handle merged cells. For example, if two columns are merged in Excel, while displaying, it will show two columns with the value in first cell and second cell will be empty. I just want to retrieve the sheet as it is. Is there any way to achieve this?
Microsoft.Office.Interop.Excel is designed to provide programmatic access to excel files. It will do some formatting work (see Text property) but most of the difficulty of rendering is left to the consumer (your program).
MergeCells will return True if you have a merged cell and MergeArea will return a Range containing the merged cells. You can then use the RowSpan and ColumnSpan fields of the GridView's cells to duplicate the functionality.

How to format numbers as string data-types while exporting to Excel in ASP.NET?

In my ASP.NET Web-form Project I have an Event which Export Data (List<Profit>) to Excel . I'm using the old fashion way , writing to HTML file with .XLS extenstionmode
Profit Entity has some string properties which has numeric data like "100000561234"
When I export to Excel , Those Columns appear like 1.00001E+11 in Excel columns, So the user has to Right-Click on Excel column and change format-cell.
Any help appreciated
Simply Add the following line before your HTML code, it will resolve the issue. This style sheet will be applied on every cell and no need to format the cell as string manually.
Response.Write("<style> TD { mso-number-format:\#; } </style>");

Categories

Resources