Dealing with OADate OpenXml Html import during Data Refresh - c#

I am facing a peculiar problem with Excel with Data Refresh.
A solution that I am working on generates an Excel on the Server using OpenXml.
In this Excel, I also add a Connection Part, which basically is a link to a webpage of my website.
This particular problem is not with English user, but if the User has Danish as the language.
When the Excel is generated, I specify a cell type as Date type (FormatId = 14)
I set the text for the cell as an OADate.
The first rendering works fine and the date is displayed correctly.
But in case of Danish, the decimal value of the OADate is stripped off and a large date is rendered making Excel show ######## (date to large)
But during Data Refresh, when Excel tries to refresh based on the data my webpage sends as Html table, Excel strips the decimal and a long number is placed in the date time cell.
I tried setting the style of the cell based on advice available here: Format HTML table cell so that Excel formats as text?
But it seems there is a difference in the way OADate works. Does anyone know what is the best way to construct the Html for Excel Data Refresh in case of OADate.
By changing the Html to have a cell value as Text work, but I want my Html to pass on the OADate to Excel.
regards,
~Mayur

The delimiter "," or "." should be set as per user and then value should be set.

Related

Excel columns are stored as text but they're numeric in the database. Need most of them as "Numeric with no decimals" in the excel sheet. Using EPPlus

I am working on a report that outputs an excel file. It has 7 tabs/worksheets that the user can choose between. I got the first 5 to format correctly.
But for some reason one of the columns in the 6th worksheet and all the columns in the 7th worksheet don't work and show up as text in the excel cells. For most of them that aren't working(They're showing up as text in the excel cells) I need them formatted as Numeric with no decimals.
Below is how I'm doing the formatting for some of the stuff that worked previously. Keep in mind this worked for the previous 5 worksheets:
ws.Columns[11].Style.Numberformat.Format = "#####0.0000"; ws.Columns[13].Style.Numberformat.Format = "###,###"; ws.Columns[20].Style.Numberformat.Format = "$###,###,##0.00;($###,###,##0.00)"
I think my issue is when the data in the database is numeric and keeping it numeric in the excel sheet isn't working. Although I just checked and I've dealt with numeric types from the database that format correctly though.. Not sure why it's not working.. What am I missing here folks?

how to Export RDLC to excel with cell format

I am exporting RDLC to excel, I have id , joining date field in rdlc. I have set tablix Id textbox as "number" and for joining date as "date" . But in excel the format cells for id is showing as general instead of number.
How to make format cells for id column as number
When defining TextBox formatting, try with the Custom format.
If your ID is an integer, just set custom format to zero, like this:
After that, you can click again on "Number" and see how it is represented as a number without decimal places, like this:
The rest is easy: From ReportViewer, save the report as Excel. The format of the ID column should be Custom, but it is actually numeric. Honestly, I don’t know why Excel says it is a Custom format and not a number, but I wouldn’t worry about that.
For more info about Excel Number formatting check this out:
Number Formatting in Excel - All You Need to Know (spreadsheetweb.com)

how to format the excel to treat the cell value as text by appending an apostrophe to the cell value in c#

I'm generating excel report in c# in excel.binding data to excel through datatable.
There is one column which will consist of 16 digit number for eg.,1317722825000285 but in excel it is coming as 1317722825000280 last digit is getting replaced by 0.
So how to can I format this column value as excel Text ?
There's a great post here that may answer your question: Format an Excel column (or cell) as Text in C#?
Try formatting the cell as text and making your variable a string in C# before inserting.
Hope this helps.

Number stored as Text

I'm currently updating values in an Excel template and I keep getting my currency fields to have the green triangle in the top corner and the "Number Stored as Text" message. How do I get Excel to recognize the cell is a number and I want it to treat it that way since I already have the cell formatted as currency? (just like what happens if I'm on the cell in Excel, hit F2, and then hit enter)
Here's a simplified version of what I'm currently doing:
UInt32Value moneyFormat = report.createCellFormat(report.Stylesheet, fontIndex, backgroundIndex, borderIndex, 168);
report.UpdateValue("Workbook", "I29", "1234.56", moneyFormat, true, String.Empty);
And here's an image of what my cells look like
You might find the answer in this post:
Open XML SDK 2.0 - how to update a cell in a spreadsheet?
Probably the DataType of the cell is not set correct.

Currency format without the thousands separator (remove comma in fields in saved reports)

I currently set some of my fields on my data grid with "c2" as the FormatString. When I generate .csv reports with XtraReports by printing on the XtraGrid, the thousands separator is included in the fields formatted as "c2". I don't want to include the comma in the exported .csvs as external systems have trouble importing the data.
What are my options to remove the comma in the fields in the .csv reports?
Can I just format the data with a preceding $ sign without the thousands separator in the data grid (and what would the FormatString be for that in this case). However, I do like visually having the separator on the grid, just not the .csv file.
Is there some sort of interceptor I can write that will remove commas during report generation?
I suggest that you clear the FormatString property before exporting the grid and revert this property value back when the exporting result is ready. This looks to be the easiest solution to this problem.
Hm... why don't you clone whole grid, assign the datasource to the new one, change the formatting and then print. Is that viable solution to you?

Categories

Resources