+ Reply to Thread
Results 1 to 7 of 7

how to maintain the cell width- convert excel to text or prn file?

  1. #1
    Registered User
    Join Date
    04-02-2009
    Location
    novato, california
    MS-Off Ver
    Excel 2003
    Posts
    10

    how to maintain the cell width- convert excel to text or prn file?

    hi,

    I have some script that loops through my Excel spreadsheet and creates a text file. I have to modify it now to maintain the width of each cell, whether they have data in them or not. I am not sure how to do that.
    Can somebody give me an idea how to do that?


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: how to maintain the cell width- convert excel to text or prn file?

    Hello mcruciani,

    I am not sure what you are asking. Is the question about the layout when printed or the cell size on the worksheet before it is saved?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-02-2009
    Location
    novato, california
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to maintain the cell width- convert excel to text or prn file?

    Hi Leith!,

    The question is about how the file looks after it's created. Here's my problem- I have to send a file that is exactly( so they tell me ) the same as the Excel file. When I create the output based on what I have so far, the columns with nothing in it iare not showing up - that is, it's scrunched down to nothing because there's nothing in them.
    I think the people Im sending this to have a program that wants everything in a fixed position.

    I asked them why they wanted a .prn file. They told me they have an 'old' system that requires it. I think they're loading this file into some other system that requires the fields to be in a fixed position.

    How do I capture the width of the cell when writing out the file? Is that possible?

    thanks.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: how to maintain the cell width- convert excel to text or prn file?

    How do you decide what the column widths should be? What if a given cell's contents doesn't fit within that width?

    What if the cell's columns were separated by tabs, and the rows by CR/LF -- would that work?
    Last edited by shg; 05-06-2009 at 07:13 PM.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    04-02-2009
    Location
    novato, california
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to maintain the cell width- convert excel to text or prn file?

    They provided me with a template that will be used by the end-user. each cell looks large enough to handle the type of field it would hold.



    I did suggest sending a tab or comma delimited file, but they didn't want it!

    thanks-
    Last edited by mcruciani; 05-06-2009 at 08:03 PM. Reason: correction-

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: how to maintain the cell width- convert excel to text or prn file?

    And any longer cell contents would be truncated to that width?

  7. #7
    Registered User
    Join Date
    04-02-2009
    Location
    novato, california
    MS-Off Ver
    Excel 2003
    Posts
    10

    Re: how to maintain the cell width- convert excel to text or prn file?

    so far I have not seen contents that are longer. THe problem is when they are shorter- that's when the cell length becomes as long as the contents.
    For example, if a cell width is 10, and the contents is "100.00" they want the text to be justified left, with 4 spaces at the end in the prn file. Does that make sense? like this:

    100.00 next field next field.... etc. instead of
    100.00nextfield

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1