× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Try this:  (Look at it in fixed font)  CSV =
apostrophe-quote-comma-quote-apostrophe
CSVBeg abd CSVEnd = apostrophe-quote-apostrophe
I'd be very surprised if this did not work perfectly for you.
 
 
     *=========================================================
      *   Create the fields for the CSV file.  This is to deal with
      *   the problem of leading/trailing blanks and embedded commas.
      *========================================================
      * CSV Description:  (from the web)
      * A file format used primarily to transfer basic data between
databases and spreadsheets.
      * Each line (up to the carriage return) is considered a record.
      * Fields within each record are divided by a comma.
      * Each line must have the same number of fields (commas).
      * If a comma or leading and/or trailing blanks appear in any field
value the field must
      * be enclosed by quotes (") to indicate the information is data and
not a field divider.
     D CSVBeg          C                   '"'
     D CSV             C                   '","'
     D CSVEnd          C                   '"'
 
      **===================================================
      **    Mainline Code
      **===================================================
 
     C                   Eval      PXX_OREC   =
     C                                 CSVBeg + ProdCode
     C                               + CSV    + %TrimR(Descript)
     C                               + CSV    + %Char(FixedCost)
     C                               + CSV    + %Char(VarCost)
     C                               + CSV    + %Char(FixedCost + VarCost)
     C                               + CSV    + %Char(SellPr)
     C                               + CSVEnd
      **==============================================================
      **   Create first row to have nice column heading literals
      **==============================================================
     C     HEADING       BEGSR
 
     C                   EVAL      PXX_OREC   =
     C                                  CSVBeg + 'Product'
     C                                + CSV    + 'Description'
     C                                + CSV    + 'Fixed Cost'
     C                                + CSV    + 'Variable Cost'
     C                                + CSV    + 'Total Cost'
     C                                + CSV    + 'Selling Price'
     C                                + CSVEnd
 
     C                   ENDSR
      **=================================================== 
 
 
 
---------------------------------------------------------
Booth Martin   http://www.MartinVT.com
Booth@xxxxxxxxxxxx
---------------------------------------------------------
 
-------Original Message-------
 
From: RPG programming on the AS400 / iSeries
Date: Tuesday, May 13, 2003 9:09:41 PM
To: RPG programming on the AS400 / iSeries
Subject: Re: AS400 to EXCEL
 
 
>>As soon as you attempt to export a
>>file with New Jersey zip codes in it, you will see that Excel will not
keep
>>the leading zeros of a CSV file, no matter what you do. Believe me, I've
>>tried.
 
>Sure it will. Going back to the days of Lotus 1-2-3, you can control the
>formatting of a cell by a leading character. Place a single apostrophe in
front
>of the text you enter into a cell and it becomes a left-aligned text entry
even
>if the entire data portion are digits.
 
>Try it when keying in Excel (or Lotus 1-2-3 <g>) and you'll see what I
mean.
>You should see the little green triangle in the upper left corner of the
cell,
>signifying it is a text formatted cell.
 
Very familiar with that trick. Works like a charm in XLS files.
 
>It also works on importing text from a
>CSV, as best I can recall.
 
If you can get this to work in a CSV, then I'm obviously doing something
wrong, so please help me out. If I copy the following text into a file,
end the filename in .csv and open it in Excel, I do get text formatting,
but I also get the apostrophes displayed.
 
'07739,'07739,'07739,'07739,'07739,'07739,'07739,'07739
'07740,'07740,'07740,'07740,'07740,'07740,'07740,'07740
'07741,'07741,'07741,'07741,'07741,'07741,'07741,'07741
'07742,'07742,'07742,'07742,'07742,'07742,'07742,'07742
'07743,'07743,'07743,'07743,'07743,'07743,'07743,'07743
'07744,'07744,'07744,'07744,'07744,'07744,'07744,'07744
'07745,'07745,'07745,'07745,'07745,'07745,'07745,'07745
'07746,'07746,'07746,'07746,'07746,'07746,'07746,'07746
'07747,'07747,'07747,'07747,'07747,'07747,'07747,'07747
'07748,'07748,'07748,'07748,'07748,'07748,'07748,'07748
'07749,'07749,'07749,'07749,'07749,'07749,'07749,'07749
'07750,'07750,'07750,'07750,'07750,'07750,'07750,'07750
'07751,'07751,'07751,'07751,'07751,'07751,'07751,'07751
'07752,'07752,'07752,'07752,'07752,'07752,'07752,'07752
'07753,'07753,'07753,'07753,'07753,'07753,'07753,'07753
'07754,'07754,'07754,'07754,'07754,'07754,'07754,'07754
'07755,'07755,'07755,'07755,'07755,'07755,'07755,'07755
'07756,'07756,'07756,'07756,'07756,'07756,'07756,'07756
'07757,'07757,'07757,'07757,'07757,'07757,'07757,'07757
 
I suppose it is technically formatted as text, but my users weren't very
happy with the unwanted apostrophes. Believe me, I have tried everything I
can think of to fool Excel into treating an all numeric cell in a CSV as
text. Leading and trailing spaces don't work. Single apostrophes (or any
other leading text character) show up. I've tried low hex values, and they
show up as funny characters or little rectangles.
 
If there is a way to make this work in Excel '97, I would be happy to know
about it, and I would recommend it to anyone who asks. But I certainly
haven't found it.
 
Mike E.
 
 
 
 
_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
 
. 


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.