ehxz 发表于 2007-6-26 12:11:05

[转帖] PB如何连接到Excel

<table cellspacing="0" cellpadding="0" width="95%" align="center" border="0"><center><tbody><tr><td height="22">&nbsp;</td><td class="p7" width="100%" height="22"><div align="left"><p align="center"><b><font face="宋体">PB如何连接到Excel</font></b></p></div></td><td height="22">&nbsp;</td></tr><tr><td colspan="3">  </td></tr><tr><td>&nbsp;</td><td class="p3" width="100%"><font face="arial, helvetica, geneva"><p><font face="arial, helvetica, geneva">This document describes how to prepare and define an EXCEL data source in order to connect to it using the Intersolv/Merant ExcelWorkbook ODBC driver. It is a supplement to the connection information found in the "Connecting to your database" manual provided with the PowerBuilder documentation. </font></p></font><p><font face="arial, helvetica, geneva"><b><font size="+1">To prepare an Excel Data source for use within PowerBuilder</font></b>
                                                                <br/>In order for PowerBuilder or InfoMaker to access an Excel data source, the Excel file must be a database. An <b>Excel database</b> is an Excel XLS workbook file that contains one or more named lists. An <b>Excel list</b> is a labeled series of worksheet rows that contain similar information (table). </font></p><p><font face="arial, helvetica, geneva">When you use an Excel workbook as a database, each list is analogous to a database table, the list rows correspond to database records, and the list columns correspond to database fields. When you connect to an Excel database in PowerBuilder or InfoMaker, the list names display in the Select Tables list in the Database painter. </font></p><p><font face="arial, helvetica, geneva">The first 'row' should be your 'column' names<b>. </b>Carefully look at all of the column headings that you intend to import into the database. SQL rules of column names are more strict than Excel. Therefore you need to modify all column headings to comply with the SQL standards. In most cases this involves removing any embedded blanks and non alphanumeric characters. For example the column name First...Name or First Name will cause errors. The column names should be changed to firstname or first_name. <br/>If you can not change the column or table names as suggested above, you can put DelimitIdentifier = 'YES' in the DBParm when you create a profile in PowerBuilder. </font></p><p><font face="arial, helvetica, geneva">Make sure your Excel workbook file contains one or more named lists. Your list name should follow standard SQL naming conventions. </font></p><p><font face="arial, helvetica, geneva">In order to define your list: <br/>In order to define your list, select (highlight) the rows and columns that are to be imported. Select Insert-&gt;name-&gt;define from the Excel menu bar to define the current workbook selection as a database table or type a name (uppercase) in the Name Field and hit &lt; enter &gt;. It is advised to always use all uppercase characters when naming tables and columns that you want to access in PowerBuilder and InfoMaker and avoid using database-specific reserved words. <br/><b><font size="+1">To define an Excel data source for the Intersolv/Merant ExcelWorkbook</font></b>
                                                                <br/>In PowerBuilder select the Configure ODBC toolbar item. If this is not on your Toolbar, press on the right mouse button on the powerbar, click on customize and drag the ODBC toolbar item down to the current toolbar. </font></p><p><font face="arial, helvetica, geneva">Once you click on the configure ODBC toolbar you will get a dialog box containing the installed ODBC drivers. Scroll down the list and select the Intersolv or Merant ExcelWorkbook and click the Create command button <br/>You will be presented with another dialog box. <br/>Give your data source a name and enter the full path for the excel database file in the Database workbook including the excel database file. <br/>Then click on the DB Profile toolbar. Select the Excel profile. It will display a window with title 'Choose an Excel Workbook as database'. Select the Excel workbook where you have saved your table, click "Open" and connect to the newly created excel data source. <br/>Click on the database icon and you should see your saved excel spreadsheets as tables. </font></p><p><font face="arial, helvetica, geneva"><b>If there are no tables in the list:</b>
                                                                <br/>Make sure the directory where the spreadsheets are located is set correctly in the ODBC datasource. <br/>Makes sure you highlighted the rows and columns in the spreadsheet. <br/>Makes sure you followed the above described instructions on how to create one or more lists in your workbook. </font></p><p><font face="arial, helvetica, geneva"><b><font size="+1">Common Error messages</font></b>
                                                                <br/><b>Cannot open workbook nnnn.xls , OLE error code (32</b>) <br/>Excel is still open, close Excel and you should be able to connect. </font></p><p><font face="arial, helvetica, geneva"><b>Select error : SQLSTATE = S1000 </b>
                                                                <br/><b>Cannot open workbook nnnn.xls , OLE error code (80</b>) <br/>The Excel file was created with a previous version of Microsoft excel. You should update it to <br/>current MS Excel format. </font></p><p><font face="arial, helvetica, geneva"><b>Select error : SQLSTATE = S0002 </b>
                                                                <br/><b>the table nnnn was not found in the workbook nnnn</b>
                                                                <br/>Table names do not comply with the SQL standards. Use uppercase characters to name your table OR set DelimitIdentifier = 'YES' in the DBParm, in the database Profile for your Excel connection. Do not use database-specific reserved words (eg: Naming an excel table 'DATABASE'). </font></p><p><font face="arial, helvetica, geneva"><b>Select error : SQLSTATE = S0022 INTERSOLV] </b>
                                                                <br/><b>Field not found: nnnn</b>
                                                                <br/>Column names do not comply with the SQL standards. Change them to follow the SQL standards OR set DelimitIdentifier = 'YES' in the DBParm, in the DataBase Profile for your Excel connection. </font></p><p><font face="arial, helvetica, geneva"><b>table nnnn has no columns, possible invalid table format</b>
                                                                <br/>Intersolv driver does not recognize input as a valid Excel file. </font></p></td><td>&nbsp;</td></tr></tbody></center></table><p>&nbsp;</p>

looks 发表于 2008-4-8 17:08:28

<p>可否增加一个中文的呢?</p>
页: [1]
查看完整版本: [转帖] PB如何连接到Excel

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com