我可以从 Foxpro 通用字段中提取文件吗? [英] Can I extract a file from a foxpro general field?

查看:22
本文介绍了我可以从 Foxpro 通用字段中提取文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将 VFP 9 应用程序移植到 SQL Server.VFP 应用程序有一些带有常规"字段的表.查询字段时得到一个字节数组,保存到磁盘时,可以查看里面是word文档,还是Paint BMP等.

通过阅读,我发现常规字段是一种专有格式,并包含文档预览的缩略图(除其他外,我敢肯定).

有人可以指出一些代码,首先提取文件类型,然后提取我可以保存为原始文件的实际文件数据.(把预览图弄出来也不错.)

显然在那天,有人在 foxpro 中编写了一个名为 GENTOFIL.PRG 的程序,听起来像是将一般字段转换为文件.但是,谷歌在试图找到它时并没有多大帮助!

解决方案

如果您知道 General 字段的内容是 Word 文档,我有一些人推荐的 Visual FoxPro 代码可以提取它.

<前>* 首先以编程方式创建表单loForm = CREATEOBJECT("表单")* 使用常规字段打开您的 VFP 表.根据需要更改名称在 0 ALIAS WordData 中使用 CustomerDocs.DBFloForm.AddObject("oleWordDoc", "oleBoundControl")loForm.oleWordDoc.AutoSize = .T.* 将通用字段绑定到 oleboundcontrolloForm.oleWordDoc.ControlSource = "WordData.gen1"lnCounter = 1扫描* 文件名均以计数器结尾* 您可能在表的另一列中有文件名.lcFileName = "docfromgeneralfield" + TRANSFORM(lnCounter)lcFileName = FORCEEXT(lcFileName, "doc")* 将数据从一般字段保存到 .doc 文件loForm.oleWordDoc.SaveAs("lcFileName")lnCounter = lnCounter + 1端扫描发布 loForm在 (SELECT("WordData")) 中使用返回

如果您需要帮助从表格中提取图像,您可以查看我过去使用过的 Microsoft 知识库文章.

http://support.microsoft.com/kb/894819

里克·舒默视觉 FoxPro MVP

I'm porting a VFP 9 application to SQL Server. The VFP app has some tables with "general" fields in them. I get a byte array when query the field, and when I save it to disk, I can look inside and see it's a word document, or a Paint BMP, etc.

From reading around, I've found that the general field is a proprietary format and contains a thumbnail image of the preview of the document (amongst other things, I'm sure).

Can somebody point me to some code that would extract firstly the type of file, and then the actual file data that I can save as the original file. (Getting the preview image out would be nice too.)

Apparently back in the day, somebody wrote a program in foxpro called GENTOFIL.PRG which sounds like it converts general fields to a file. But, google doesn't help much when trying to find that!

解决方案

If you know the content of the General field is a Word Document I have some Visual FoxPro code recommended by someone that should extract it.

* First create a form programmatically
loForm = CREATEOBJECT("Form") 

* Open your VFP table with the general field. Change name as needed
USE CustomerDocs.DBF IN 0 ALIAS WordData

loForm.AddObject("oleWordDoc", "oleBoundControl") 
loForm.oleWordDoc.AutoSize = .T. 

* bind general field to oleboundcontrol 
loForm.oleWordDoc.ControlSource = "WordData.gen1" 

lnCounter = 1

SCAN 
   * File names all the same with counter at end
   * You might have file name in another column in the table.
   lcFileName = "docfromgeneralfield" + TRANSFORM(lnCounter)
   lcFileName = FORCEEXT(lcFileName, "doc")

   * save data from general field to .doc file 
   loForm.oleWordDoc.SaveAs("lcFileName") 

   lnCounter = lnCounter + 1 
ENDSCAN 

RELEASE loForm

USE IN (SELECT("WordData"))

RETURN

If you need help extracting an image out of the table you can check out a Microsoft KB article I have used in the past.

http://support.microsoft.com/kb/894819

Rick Schummer Visual FoxPro MVP

这篇关于我可以从 Foxpro 通用字段中提取文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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