I have created an asp.net website,which stores data into an ms-excel sheet from the webpage,the problem is,all other column values except the first column(register number)are correct.when we open the sheet it displays a value "2.11511E+11" in the register number column.Why so? Im new to using ms-excel,pls help. And the datatype i used for register number is "long".
This is just the format of the cell (represention)
Look at this tutorial to change represention
Related
I got stuck for setting "ReadOnly" column using "ClosedXML" utility for export to Excel.
I am able to export records into Excel, however the first "ID" column I need to keep it read only, user should not type anything. If he want to add new row in the exported excel he can, except "ID" column. Please help me to solve this functionality (ws is my worksheet).
ws.Column("ID").Style.Protection.SetLocked(true);
Even I am setting "SetLocked" it is editable and I need non-editable field.
You need to also switch protection on for the worksheet with
ws.Protect()
See the documentation and this question for more details.
at first you need to protect the whole sheet then unlock only the cells you want to be editable as following
ws.Protect("yourPassword"); //hint: password parameter is optional
ws.Column("ID").Style.Protection.SetLocked(false); //set to false
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.
I have requirement to export SQL Script data to an excel using C#.Net.
Currently I face issue in avoiding duplicat values for columns, when a record has multiple values for a column it should look like as in the bellow, the entire record should not repeated for each values of the column.
should I handle it in application level or in Sql script. please advice me.
Currently I get data set and bind it to a grid view and then do the export to excel function.
for example Sql Data could be
select B.BID, B.BName, M.Year
from tbl_B B
inner join tbl_Master M ON B.BID = fm.BIDFK
where B.BName = 'B9'
Group By B.BID, B.BName, M.Year
And the Result
I have cleared out this issue on C# side, I use nested grid-view to bind multiple valued columns for a record, when exporting to excel clear controls inside the parent grid-view to export data from all grid-view.
I think it need to be done in SQL script.
It's not complicated logic to apply .
I would seriously look at using the Report Viewer control and a local report rather than trying to build the Excel sheet by hand. Check out GotReportViewer.com and the examples on the right cover exporting to Excel, and using the control from a console application.
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
I have a asp.net page in which i am exporting gridview records to the excel files. But in some records only ############# is displayed in the excel file & when i view that record in function bar of the excel i am able to view correct record. So what can be the problem?
Waiting for your reply.Thanks a lot in advance.
Thanks
Mehul Thakkar
Make the columns wide enough so that the entire number can be displayed.
####### in the cell only means that the cell is too narrow to fit the value (for some data types). If you make it wider the problem will disappear.