Generating a CSV file - excel

I am having problems converting an MSaccess table that contains a 12 digits barcode-number field to CSV file
The barcode field is defined as text!
I tried exporting to Excel and saving the Excel file to CSV or exporting it to CSV But but that did not work either (even when the field is defined as text).
The problem is that some barcodes start with zero which gets truncated and that displays a scientific notation instead of displaying the barcode string.
My Question is: How can I generate a CSV file that is stored as an Excel spread sheet?
any help is appreciated
Dory
Nick McDermaid thanks for your comment. When looking in a text editor everything looks perfect.....You mean the people requesting it on my website are actually using it as text file and do not care about the way it looks in a spread sheet? if so then I am just chasing a wild goose! is that what you mean?

Related

office 365 excel csv hyperlink not displaying correctly when imported to excel [duplicate]

Can Excel interpret the URLs in my CSV as hyperlinks? If so, how?
You can actually do this and have Excel show a clickable link. Use this format in the CSV file:
=HYPERLINK("URL")
So the CSV would look like:
1,23.4,=HYPERLINK("http://www.google.com")
However, I'm trying to get some links with commas in them to work properly and it doesn't look like there's a way to escape them and still have Excel make the link clickable.
Does anyone know how?
With embedding the hyperlink function you need to watch the quotes. Below is an example of a CSV file created that lists an error and a link to view the documentation on the method that failed. (Bit esoteric but that's what I am working on)
"Details","Failing Method (click to view)"
"Method failed","=HYPERLINK(""http://some_url_with_documentation"",""Method_name"")"
I read all of these answers and some others but it still took a while to work it out in Excel 2014.
The result in the csv should look like this
"=HYPERLINK(""http://www.Google.com"",""Google"")"
Note: If you are trying to set this from MSSQL server then
'"=HYPERLINK(""http://www.' + baseurl + '.com"",""' + baseurl + '"")"' AS url
you can URL Encode your commas inside the URL so the URL is not split across multiple cells.
Just replace commas with %2c
http://www.xyz.com/file,comma.pdf
becomes
=hyperlink("http://www.xyz.com/file%2ccomma.pdf")
Yes, but it's not possible to link them automatically. CSV files are just text files - whatever opens and reads them is responsible for allowing you to click the link.
As to how Excel seems to handle CSV files - everything between commas is interpreted as if it already had been typed into the cell. Therefore, the CSV file containing ="http://google.com",=A1 will display as http://google.com,http://google.com in Excel. It's important to note, however, that hyperlinks in Excel are metadata, and not the result of anything in the actual cell (ie, a hyperlinked cell to Google still contains http://google.com not <a>http://google.com</a> or anything of that sort.)
Since that's the case, and all metadata is lost when converting to a CSV, it's impossible to tell Excel you wish for something to be hyperlinked merely by changing the cell value. Normally, Excel interprets your input when you hit 'Enter' and links URLs then, but since CSV data is not being entered, but rather already exists, this does not happen.
Your best bet is to write some sort of addon or macro to run when you open up a CSV which parses every cell and hyperlinks them if they match a URL format.
Use this format:
=HYPERLINK(""<URL>"";""<LABEL>"")
e.g.:
=HYPERLINK(""http://stackoverflow.com"";""I love stackoverflow!"")
P.S. The same format works in LibreOffice Calc as well.
"=HYPERLINK(\"\" " + "http://www.mywebsite.com"+ "\"\")"
use this format before writing to CSV.
As described above, "=HYPERLINK(""http://www.google.com"", ""Google"")" is what worked for me.
However, In Excel Version 2204 Click to Run, I couldn't have leading white space.
For example;
FirstName, "=HYPERLINK(""http://www.google.com"", ""Google"")" fails
FirstName,"=HYPERLINK(""http://www.google.com"", ""Google"")" success
The issue here for me was that because a .CSV by it's nature is Comma separated, any commas in the text file are interpreted as separators. It worked for me by using tab characters as separators, saving it as a .TXT file so that when opened in EXCEL you choose the TAB character rather than ','.
In the text file …
## ensure that the file is TAB separated
Item 1 A file Name data.txt
Item 2 Col 2 =HYPERLINK("http:\www.ilexuk.com","ILEX")
"ILEX" then is shown in the cell and "http:\www.ilexuk.com" is the hyperlink for the cell.

Column width style lose when converting .xls to csv

I am exporting an .xlsx document to .csv but I during that conversion I am loosing the complete style. Column width style is loosing terribly I was using Mac OS Numbers app but If i remember it correctly same issue happened with Microsoft excel ( I do not have the windows machine to cross check that for the moment).
original excel image
Exported csv image
I was wondering whether this is an application related issue or is it something wrong in general.
Did anyone face the same issue ? I do not have idea about where to begin to solve the styling issue. Some pointer will be greatly appreciated.
I added apache poi tag because I created the original excel using apache-poi
CSV stands for "Comma Separated Value".
CSV is a text file. Basically, you can open it with Excel or with a basic text editor. It is not made for storing formatting.
If you need to deal with formatted table then you have to choose another format.

Excel .CSV File UTF -8 Encoding not working

I've got an application that exports a .CSV file with many data, however every time where there is an accent, the files changes the letter to $#231;,
Already converted the file and the text to UTF-8 and it does not fix the problem
Tried the conversion with Excel and also Open Office without success.
Does anybody have any idea how to fix this issue ?
Follow an example of wrong data extracted (the text is in Brazilian language):
Lol, after i paste the wrong data in the StackOverflow text to post, the data convert to the correct data.
Anybody has any idea ?
Data Conversion Correctly

How to save excel columns with long numbers into csv?

Funny thing when I want to save Excel columns with long numbers like below, resulting csv contains converted numbers to scientific notation which is unusable. I want them to be save as text. Any trick to do that?
28160010390002003505456159
12160010390002003505456156
39160010390002003505456155
39160010390002003505456155
Append a TAB char (ASCII 9) at the end of a number.
In order to have those long (>15 digit) numbers in Excel, they are already formatted as text. I suspect that the .csv file also shows them as long numbers (if you open the csv file with Notepad), but that when you open the csv file in Excel, you see them as truncated and converted to scientific notation.
If that is the case, what you need to do is IMPORT the csv file. When you do that, the text-to-columns wizard will open, and allow you to format that column as text. The location of the Import is different in different versions. In Excel 2007, it is on the Data ribbon, Get External Data / From Text.
put the number as a function like below:
="123456789123456789"
If, as the original question seems to imply, you are actually:
already working with data in Excel, and
want to save to a CSV format without losing digits in an extra long number,
Then, before doing a 'Save As' to your CSV format, try formatting the column with a custom format, and in the box for the pattern just type #. This will force Excel to see it as a number, however many digits long, without trying to do something else with it like 4.52364E+14 when you actually save it to CSV.
At least, that is how it works for me in Excel 365 at this point in time.
If you are trying to get data into Excel from a CSV, then the answer about using the data import wizard is probably the safest bet instead.
This is an old question, but since at the moment it's still the top result on a google search for the topic, I think the thread should be kept current. Hussein mahyoub provided the only real answer to the question, yet has not gotten the up-votes.
The answer which tells us to add a tab character after your number gets you an string of text with a tab after it inside excel. It looks visually correct, but, it's not correct inside the spreadsheet. If the intent is to use the data in excel as excel data and use formula etc, it could cause problems. Interestingly if you put the tab before the text, it shows up in the data after the text.
The answer which tells us inserting a ' before the text gets a ' in the excel file. It's visually an incorrect representation of the data.
The answer which boasts the virtue of openoffice is simply an evil troll which does not even attempt to answer the question.
The answer that explains how to import a CSV that has not been properly formatted is good information, but, off topic.
The direct answer to the question is
converted to text,largest number
="123456789012",12345678901
Convert the numeric to text using text function.
Text(number,"0")
using openoffice you can save in csv format without problems.
Don't use Export to csv feature in Excel.
You can easy format that column to number in Excel, then use "Save as" it with csv and "yes" to confirm that you want to keep the format in csv.
That is work for me
Click on the column that has scientific exponent number and go to Format cells and then Numbers (decimal point as 0), save it as MSDOS CSV. Worked for me.

CSV Exporting: Preserving leading zeros

I'm working on a .NET application which exports CSV files to open in Excel and I'm having a problem with preserving leading zeros when the file is opened in Excel. I've used the method mentioned at http://creativyst.com/Doc/Articles/CSV/CSV01.htm#CSVAndExcel
This works great until the user decides to save the CSV file within Excel. If the file is opened again in Excel then the leading zeros are lost.
Is there anything I can do when generating the CSV file to prevent this from happening.
This is not a CSV issue.
This is Excel loving to play with CSV files.
Change the extension to something else.
As #GSerg mentions, this is not a CSV issue.
If your users must edit/save in Excel they need to select the entire worksheet, right-click and choose "Format Cells" and from the Category list select "Text" after opening the csv file. This will preserve the leading zeros since the numbers will be treated as simple text.
Alternatively, you could use Open XML SDK 2.0, or some other Excel library, to create an xlsx file from your csv data and programmaticaly set the Cell type to Text in order to take the end users out of the equation...
I found a nice way around this, if you add a space anywhere along the phone number, the cell is then not treated as number and is treated as a text cell in both Excel and Apple's iWork Numbers.
It's the only solution I've found so far that plays nice with Numbers.
Yes I realise the number then has a space, but this is easy to process out of large chunks of data, you just have to select a column and remove all spaces.
Also, if this is web related, most web type things are ok with users entering a space in the number field. E.g you can tap-to-call on mobiles.
The challenge is to get the space in there in the first place.
In use:
01202123456 = 1202123456
but
01202 123456 = 01202 123456
Ok, new discovery.
Using Quick Preview on Mac to view a CSV file the telephone column will display perfectly, but opening the file fully with Numbers or Excel will ruin that column.
On some level Mac OS X is capable of handling that column correctly with no user meddling.
I am now working on the best/easiest way to make a website output a universally accepted CSV with telephone numbers preserved.
But maybe with that info someone else has an idea on how to make Numbers handle the file in the same way that Quick Preview does?

Resources