I am trying export gridview to csv.
I am adding actual record into cell of excel not trying html to excel.
I am executing sp, taking record into datatable.
Looping through datatable, writing into file using streamwriter.
But problem occur when my column has long number, csv shows 890+32 like this.
I don't want like this, want actual number like 89012345676898899998776766544333445556677.
How to do that? I am not using Gridview.RenderControl(htmltextwrtter).
Try to cast the number into a String and add a leading ' to force excel to see the entry as text, like this:
'89012345676898899998776766544333445556677
Otherwise excel will see them as numbers (which they are, of course) and auto-format them in the unwanted format.
Related
I have a csv like this:
"Data,""Ultimo"",""Apertura"",""Massimo"",""Minimo"",""Var. %"""
"28.12.2018,""86,66"",""86,66"",""86,93"",""86,32"",""0,07%"""
What is the solution for importing correctly please?
I tried with read.csv("IT000509408=MI Panoramica.csv", header=T,sep=",", quote="\"") but it doesn't work.
Each row in your file is encoded as a single csv field.
So instead of:
123,"value"
you have:
"123,""value"""
To fix this you can read the file as csv (which will give you one field per row without the extra quotes), and then write the full value of that field to a new file as plain text (without using a csv writer).
I would like to export a large table (similar to that shown in the image below) to Excel with parts of the string highlighted in few of the columns.
At present I am displaying the table columns using datatable employing rowCallback function to highlight the sub string. Then to export the table to Excel, I am manually copying the rows from the displayed datatable to an Excel worksheet.
I could not accomplish this particular challenge using openxlsx or other libraries.
Please advice on how to overcome this challenge!
How do i extract a number formatted column when i spool to a csv file from unix when the column is varchar in database?
Number format in CSV is 5.05291E+12
should actually be 5052909272618
This problem is not a Unix or ksh problem, but an Excel problem. Assuming Excel is the default application for a .csv file, When you double-click to open in Excel, it makes the column type "General" by default and you get the scientific notation instead of the text value as expected. If your numeric data has leading zeroes they will be removed also.
One way to fix is to start Excel (this example in the 2010 version), the go to Data/get external data/from text, follow the wizard making sure to set the "column data format" to "text" for the column that contains your large number (click on the column in the "data preview" section first). Leading zeroes will be preserved also.
You could code a vba macro that would open with all columns as text (a little searching will show you some examples) but there seems to be no place to tell Excel to treat columns as "text" by default.
There was need to develop report and I was also facing the same issue.i found that there is one workaround/solution. e.g.
your table name --> EMPLOYEE
contains 3 columns colA,colB,colC. the problem is with colB. after connecting to sqlplus you can save the the data in spool file as :
select colA|| ','''||colB||''',' ||colC from employee
sample result:
3603342979,'8938190128981938262',142796283 .
when excel opens the file it displays the result "as-it-is"
I am currently trying to import an excel spreadsheet that contains product data for products on my website.
Of the various fields available for product import, one of them is the product description. In this cell, I paste the HTML data that I wish to be displayed on that product.
However, it would seem that sometimes excel decides to format this data on it's own, and after importing, the HTML is all screwed up. It's strange, because this does not happen on every product.
I've tried formatting the cells as "text", but that seems to have no effect. When I paste the values from the cell into notepad, I can see that every singe quote symbol (") has been doubled. For what reason, I have no idea.
The data looks correct when viewed in the cell, but it does not import properly, and the data is visibly changed when copied and pasted out of excel.
Any ideas on how to remedy this? How can I get excel to just ignore the data?
Try putting the HTML code in a single line with no breaks. For example:
<html><body><p><div id="PDG-Team-Image">Test</body></html>
I ran a quick test using the above simple HTML snippet. In Column A, I put the code with line breaks. In column B, I put the code with no breaks. I then copied the cell A1 and pasted it into Notepad, and then copied B1 and pasted it into Notepad. You'll see the first paste (A1) has the double quotes. The second paste (B1) has no double quotes.
I have this sql server query that I am running in my .net app.
(CONVERT(VARCHAR(8), EventDate, 112)+ substring(RequestedBy,1,1)+right( '0000000' + convert( varchar( 7 ), ContactID ), 7 )) as Contacts
It produces the following results in the following format:
20120731e0000001
20120731f0000002
20120731p0000003
This is the result and format that we want.
Problem is when we click on export icon to export these results to excel, the first one changes to the scientific format like 2.01E+08.
Any date that has e in the middle such as 20120731*e*0000001 turns into scientific data.
The rest is just fine.
Any ideas how to fix this?
I want to apologize in advance if I stick the wrong tag in the Tags section since I am not sure where the fix could come from.
The formatting is happening when Excel opens your exported file. Simply change the column to have "formatted text" of string so that it displays as the original format.
When you open the exported data file directly with Excel, all formats are set as General. In General format, Excel applies formatting to what it recognizes as numbers and dates. So, to be clear, the issue is not with your export, but rather with how Excel is reading your data by default. Try the following to get around this issue.
Export to CSV. Then, rather than opening the CSV in Excel, use Excel's 'Get External Data From Text' tool to import the data into an empty workbook. Here you can specify to treat this field as TEXT rather than as GENERAL.
Note that once Excel applies number (or date) format to a cell, the data in the cell has been changed. No application of a new format will bring back your desired data. For this reason you must specify the format before Excel opens the file.