简体   繁体   English

如何从DB2中的Excel工作表中读取数据

[英]How do I read data from a excel worksheet in DB2

I need to write a Stored Proc/ Function which reads data from a worksheet of Excel workbook. 我需要编写一个存储的Proc /函数,该函数从Excel工作簿的工作表中读取数据。 How do I do it in DB2 ? 我如何在DB2中做到这一点? I am using AIX os. 我正在使用AIX操作系统。

Tried Read Excel from DB2 but wont work on my OS. 尝试从DB2中读取Excel,但无法在我的OS上使用。 Also tried 也尝试过

Import from FileName.csv of DEL COMMITCOUNT 1000 insert into TableName 

but invain. 但徒劳。

You have several options, the cleanest is probably to write a Java Stored Procedure , utilising the Apache POI library, if you intend to read Excel workbooks (.xls or .xlsx) rather than plain CSV formatted text files. 您有几种选择,如果您打算读取Excel工作簿(.xls或.xlsx)而不是纯CSV格式的文本文件,则最干净的方法是使用Apache POI库编写Java存储过程

Not as clean but just as effective you can write a Perl / Python / PHP script to read the file and return a line at a time, and invoke the script from a stored procedure, see: Making Operating System Calls from SQL 您可以编写一个Perl / Python / PHP脚本来读取文件并一次返回一行,并从存储过程中调用该脚本,但效果不尽如意,请参见: 从SQL进行操作系统调用

Its be better to convert your excel file to flat file like csv if possible. 如果可能的话,最好将您的excel文件转换为csv之类的平面文件。 Because DB2 not natively know excel file. 因为DB2本身不是Excel文件。 Its csv file that can processed natively using IMPORT, LOAD or INGEST tools from DB2 可以使用DB2中的IMPORT,LOAD或INGEST工具本地处理的csv文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM