Previous Thread
Next Thread
Print Thread
Leading zeros in Excel #37817 13 Feb 25 03:23 PM
Joined: Nov 2007
Posts: 57
R
René Villar Offline OP
Member
OP Offline
Member
R
Joined: Nov 2007
Posts: 57
Hello!!

We have a CSV file that contains bank account numbers, which have several leading zeros. We transfer this file to the PC to pass it directly to Excel, that is, without going through APEX.

In the CSV the leading zeros are present, but when passing them to Excel, it gives them a numerical format and the leading zeros are lost.

I understand that this is more of an Excel issue, but I'm wondering if any of you have had a similar problem and been able to resolve it by somehow configuring the Excel cell format.

What we have tried has not worked.

Thanks in advance for any ideas on this.


René.
Re: Leading zeros in Excel [Re: René Villar] #37818 13 Feb 25 03:59 PM
Joined: Jun 2001
Posts: 3,424
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,424
Hi René,
There is no magic wand that keeps those leading zeros while opening the CSV file, unless you import the CSV instead of just open it, if you do so, select Text format for the bank account column in the wizard and you'll be fine.
Otherwise the most direct way to adjust the column is to Format, Customized and type in a mask of zeros with the maximum size of the bank account (e.g.: 0000000000000 for 13 digit number).
Hope it helps

Grande abraço


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal
Re: Leading zeros in Excel [Re: René Villar] #37819 13 Feb 25 04:29 PM
Joined: Jun 2001
Posts: 11,925
J
Jack McGregor Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 11,925
Hi René and Jorge,

This might be a good opportunity for you to learn about CSV2XL. Basically, it allows you to add directives to your CSV file which are used to convert it directly to XLS or XLSX so that when the file launches on the user's PC, it looks exactly like you wanted it to, without the need for the user to navigate through the wizard and/or make changes to the spreadsheet format themselves. For example, the you could apply Jorge's mask to column #3 using the following directive:

Code
//XL,SetCol,colfirst=3,mask="0000000000000",width=14,nototal

With a relatively small amount of effort, CSV2XL allows you to vastly improve the look and usability of the spreadsheets created by your application (banners, footnotes, totals, highlighting of the headers and totals, multiple sheets, etc. etc.

Re: Leading zeros in Excel [Re: René Villar] #37820 14 Feb 25 02:09 AM
Joined: Jun 2001
Posts: 3,424
J
Jorge Tavares - UmZero Online Content
Member
Online Content
Member
J
Joined: Jun 2001
Posts: 3,424
Hi Jack,
Thank you for the reminder, that's precious if the idea is to produce a specific report.
From my experience, nowadays, I'm not producing any more reports, it's all about XTREE and directly Export CSV or XLS.
But, I have one particular case where a CSV must be uploaded with the inventory, very simple, five columns, Type, Product, Description, Qty, Unit,
It happens that, most of the times, the users need to add a few lines and there are Product codes with leading zeros and other codes are converted to exponential values.
I could use that technique to open it after creating the CSV file, but usually the file is sent to someone to do the changes.

Have a nice weekend


Jorge Tavares

UmZero - SoftwareHouse
Brasil/Portugal

Moderated by  Jack McGregor, Ty Griffin 

Powered by UBB.threads™ PHP Forum Software 7.7.3