Excel: Exporting Data to Text FilesLast reviewed: February 5, 1998Article ID: Q90914 |
The information in this article applies to:
SUMMARYMicrosoft Excel versions 3.0 and 4.0 provide an add-in macro called Flatfile.xla. You can use this macro to export all or part of a worksheet to a text file in the "flat file" format. To create a flat file in Microsoft Excel versions 5.0 and later, click Save As on the File menu, and then click Formatted Text (Space Delimited). When data is stored in the flat file format, the data is stored in fixed- width columns that are separated by spaces instead of commas or tabs.
MORE INFORMATIONThe flat file format is used to create text files that you can open in other computer programs that work only with text data. For example, this format is typically required by mainframe programs and is often necessary for government reporting. To create a flat text file, use the following method that is appropriate for your version of Microsoft Excel.
Creating a Flat Text File in Excel 5.0 and LaterTo create the file, follow these steps:
Creating a Flat Text File in Excel Versions 3.0, and 4.0 with Flatfile.xlaTo create the file, follow these steps:
Issues with Flatfile.xlaThe following sections contain information about the alignment and number formatting, column widths, and fonts in the exported data. Issue 1: Alignment and Number Formatting with Flatfile.xla: When you use the Export command to export data from your worksheet, you have the option to keep the alignment and number formatting of the cells you are exporting. You also have the option to use General alignment and number formatting for all data. When you use General alignment and number formatting, text data is aligned to the left, and numeric data is aligned to the right. Formatting, such as currency or custom number formatting, is not saved. NOTE: The Fill, Justify, and Center Across Selection formats, may cause problems when you export by using Flatfile.xla. Microsoft recommends that you remove these formats from the cells before you export the data. For additional information, query on the following words in the Microsoft Knowledge Base:
Excel: Cell Alignment Formats Cause Flatfile Export to FailIssue 2: Column Widths with Flatfile.xla: The column width in your text file is equal to the whole number portion of the column width for the selected cells. For example, if the column width is 12.45, the column in the text file will be 12 characters wide. Any characters beyond the twelfth character in a cell are not included in the text file. Before you export data, make sure that the columns in the worksheet are wide enough to accommodate all of the characters in the cells you want to export. Issue 3: Fonts with Flatfile.xla: If your worksheet is formatted with proportional fonts (for example, Times New Roman or MS Sans Serif), you may need to increase the width of the columns to insure that all of the data is exported properly. With proportional fonts, some characters are narrower than others; therefore, more characters may be in a cell than the number that is indicated by the column width. As a result, these characters are cut off when you export the data (see "Issue 2: Column Widths with Flatfile.xla"). To insure that all of the data is exported properly, format all of the data with a monospace (non-proportional) font, such as Courier, or experiment with various column widths until all of the data is exported.
REFERENCES"Microsoft Excel User's Guide," version 3.0, pages 683-684 "Microsoft Excel User's Guide 2," version 4.0, page 152
|
Additional query words: 3.0 3.00 4.0 4.00 XLA fixed length xl font export
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |