将查询结果导出到固定宽度的文本文件 [英] Exporting queried results to fixed width text file

查看:97
本文介绍了将查询结果导出到固定宽度的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有以下查询将查询结果导出到文本文件中,逗号分隔。现在我需要将它导出到一个文本文件中,但是长度固定,而不是逗号。有人可以帮我这个吗?提前致谢!

展开 | 选择 | Wrap | 行号

解决方案

嗨loisk。可以使用VB代码导出到固定宽度的文本文件。该主题的第2篇显示了如何完成它的一个例子:

http://bytes.com/forum/thread781345.html


-Stewart





我有以下查询将查询结果导出到文本文件中,逗号分隔。现在我需要将它导出到一个文本文件中,但是长度固定,而不是逗号。有人可以帮我这个吗?提前致谢!

展开 | 选择 | Wrap | 行号



你好。可以使用VB代码导出到固定宽度的文本文件。该主题的第2篇显示了如何完成它的一个例子:

http://bytes.com/forum/thread781345.html


-Stewart



谢谢,斯图尔特!

由于我缺乏VB知识,在你建议的链接中有些东西我不明白。所以我想知道无论如何我都可以通过编辑上面的行获得我想要的结果,例如... [Txt; FMT = Fixed; HDT = YES; DATABASE = .....]?


你好。啊,如果只是那么简单......虽然有多种方法可以导出数据,包括分隔文本文件格式(例如,看看使用DoCmd.OutputTo可用的选项),如果你真的需要一个固定宽度的文本文件(未被删除)你将不得不使用我链接的线程中列出的VB代码。


如果你考虑一下,要使用固定宽度格式,你必须定义输出时每个字段的宽度,以及用于表示所有非文本的格式数据类型:日期,数字,布尔值,货币,长整数,双精度等。每个字段都需要一个定制的格式 - 代码不复杂,但不容易做任何其他方式。


Access可以使用导出向导导出为固定宽度的文本格式这样做(将为每个字段创建格式)。如果您无法编写解决方案,这可能是您的最佳选择。


-Stewart


Hi,

I have the following query to export queried results into a text file, comma delimited. Now I need to export it into a text file, but with fixed length, not with commas. Can anybody help me on this? Thanks in advance!

Expand|Select|Wrap|Line Numbers

解决方案

Hi loisk. Exporting to a fixed-width text file can be done using VB code. An example of how it can be done is shown in post 2 of this thread:

http://bytes.com/forum/thread781345.html

-Stewart

Hi,

I have the following query to export queried results into a text file, comma delimited. Now I need to export it into a text file, but with fixed length, not with commas. Can anybody help me on this? Thanks in advance!

Expand|Select|Wrap|Line Numbers


Hi loisk. Exporting to a fixed-width text file can be done using VB code. An example of how it can be done is shown in post 2 of this thread:

http://bytes.com/forum/thread781345.html

-Stewart

Thank you, Stewart!
There were something that I don''t understand in the link you suggested due to my lack of VB knowledge. So I am wondering if there is anyway that I can obtain the result I want by editing the line above, something like...[Txt;FMT=Fixed;HDT=YES;DATABASE=.....]?


Hi loisk. Ahh, if only it was that simple... Whilst there is more than one way to export data, including to a delimited text file format (have a look at the options available using DoCmd.OutputTo, for instance), if you truly need a fixed-width text file (non-deliimited) you will have to do this using VB code as listed in the thread I linked.

If you think about it, to use a fixed-width format you must define the width every field will take when output, and the format which will be used to represent all non-text data types: dates, numerics, booleans, currency, long integers, doubles and so on. Each and every field requires a bespoke format - not complex to code, but not easy to do any other way.

Access can export to a fixed-width text format, using the Export wizard to do so (which will create the format for each field). Perhaps this is your best option if you are unable to code a solution.

-Stewart


这篇关于将查询结果导出到固定宽度的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆