简体   繁体   English

将SQL数据导出到Excel下拉菜单

[英]Export SQL Data to Excel Dropdown

Is it possible to export records from SQL directly to a drop down data validation list? 是否可以将记录从SQL直接导出到下拉数据验证列表?

I want to export data directly to the list without having to actually have the data saved within a sheet/table etc. 我想直接将数据导出到列表,而不必实际将数据保存在工作表/表格等中。

Step 1: Add a query data connection If you do not have an existing query data connection that you can use on your form template, follow these steps to add a secondary data connection to your form template that queries data. 步骤1:添加查询数据连接如果您没有可用于表单模板的现有查询数据连接,请按照以下步骤将辅助数据连接添加到查询数据的表单模板。 If your form template already has a secondary data connection that you can use, you can skip this section and go to Step 2: Configure the control. 如果您的表单模板已经具有可使用的辅助数据连接,则可以跳过本节并转到步骤2:配置控件。

On the Tools menu, click Data Connections. 在工具菜单上,单击数据连接。

In the Data Connections dialog box, click Add. 在“数据连接”对话框中,单击“添加”。

In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next. 在数据连接向导中,单击“创建新连接”,单击“接收数据”,然后单击“下一步”。

On the next page of the wizard, click Database (Microsoft SQL Server or Microsoft Office Access only), and then click Next. 在向导的下一页上,单击“数据库”(仅Microsoft SQL Server或Microsoft Office Access),然后单击“下一步”。

On the next page of the wizard, click Select Database. 在向导的下一页上,单击“选择数据库”。

In the Select Data Source dialog box, click New Source. 在“选择数据源”对话框中,单击“新建源”。

On the next page of the wizard, in the What kind of data source do you want to connect to list, click Microsoft SQL Server and then click Next. 在向导的下一页上,“您想连接到哪种数据源”列表中,单击“ Microsoft SQL Server”,然后单击“下一步”。

In the Server name box, type the name of the server that contains the SQL Server database. 在“服务器名称”框中,键入包含SQL Server数据库的服务器的名称。

Under Log on credentials, do one of the following: 在“登录凭据”下,执行下列操作之一:

If the database determines who has access based on the credentials used in a Microsoft Windows network, click Use Windows Authentication. 如果数据库根据Microsoft Windows网络中使用的凭据确定谁有权访问,请单击“使用Windows身份验证”。

If the database determines who has access based on a specified user name and password that you get from the database administrator, click Use the following User Name and Password, and then type your user name and password in the User Name and Password boxes. 如果数据库根据您从数据库管理员那里获得的指定用户名和密码来确定谁可以访问,请单击“使用以下用户名和密码”,然后在“用户名和密码”框中键入您的用户名和密码。

Click Next. 点击下一步。

In the Select the database that contains the data you want list, click the name of the database that you want to use, click Connect to a specific table, click the name of the primary table, and then click Next. 在“选择包含所需数据的数据库”列表中,单击要使用的数据库的名称,单击“连接到特定表”,单击主表的名称,然后单击“下一步”。

On the next page of the wizard, in the File Name box, type a name for the file that stores the data connection information, and then click Finish to save these settings. 在向导的下一页上,在“文件名”框中,为存储数据连接信息的文件键入一个名称,然后单击“完成”以保存这些设置。

If you plan to use other tables in the query data connection, you can add the other tables in this page of the wizard. 如果计划在查询数据连接中使用其他表,则可以在向导的此页面中添加其他表。

Add other tables 添加其他表格

Click Add Table. 单击添加表。

In the Add Table or Query dialog box, click the name of the child table, and then click Next. 在“添加表或查询”对话框中,单击子表的名称,然后单击“下一步”。 InfoPath attempts to set the relationships by matching field names in both tables. InfoPath尝试通过匹配两个表中的字段名称来设置关系。 If you do not want to use the suggested relationship, select the relationship, and then click Remove Relationship. 如果您不想使用建议的关系,请选择该关系,然后单击“删除关系”。 To add a relationship, click Add Relationship. 要添加关系,请单击添加关系。 In the Add Relationship dialog box, click the name of each related field in the respective column, and then click OK. 在“添加关系”对话框中,单击相应列中每个相关字段的名称,然后单击“确定”。

Click Finish. 单击完成。

To add additional child tables, repeat these steps. 要添加其他子表,请重复这些步骤。

Click Next. 点击下一步。

To store the results of the query with the form template, select the Store a copy of the data in the form template check box. 要将查询结果与表单模板一起存储,请选中在表单模板中存储数据的副本复选框。 Selecting this check box stores the query results in the form template. 选中此复选框会将查询结果存储在表单模板中。 Becuase the data is stored in the form template. 因为数据存储在表单模板中。 the data is available in the forms that users fill out, even if their computers are not connected to a network. 即使用户的计算机未连接到网络,也可以通过用户填写的表格获得数据。

Security Note: Selecting this check box stores the query results in the form template. 安全说明:选中此复选框会将查询结果存储在表单模板中。 Because the data is stored in the form template, it is available in the forms that users fill out, even if their computers are not connected to a network. 因为数据存储在表单模板中,所以即使用户的计算机未连接到网络,也可以在用户填写的表单中使用它们。 If you are getting sensitive data from this data connection, you may want to disable this feature to help protect the data in case the computer is lost or stolen. 如果从此数据连接中获取敏感数据,则可能要禁用此功能,以在计算机丢失或被盗时帮助保护数据。

Click Next. 点击下一步。

On the next page of the wizard, type a descriptive name for this secondary data connection. 在向导的下一页上,为此辅助数据连接键入一个描述性名称。 If you want the form to automatically receive data when the form is opened, select the Automatically retrieve data when form is opened check box. 如果希望表单在打开时自动接收数据,请选中“打开表单时自动检索数据”复选框。

Step 2: Configure the control If the form template has multiple views, click View name on the View menu to go to the view with the control where you want to display the data from the secondary data source. 步骤2:配置控件如果表单模板具有多个视图,请在“视图”菜单上单击“视图名称”以转到要在其中显示辅助数据源数据的控件视图。

Double-click the list box, drop-down list box, or combo box control that you want to populate. 双击要填充的列表框,下拉列表框或组合框控件。

Click the Data tab. 单击数据选项卡。

Under List box entries, click Look up values from an external data source. 在列表框条目下,单击从外部数据源查找值。

In the Data Source list, click the data source that you want to use. 在“数据源”列表中,单击要使用的数据源。

Click Select XPath Data Source button next to the Entries box. 单击“条目”旁边的“选择XPath数据源”按钮。

In the Select a Field or Group dialog box, specify what data will be shown to the user and what data will be submitted to the external data source by doing one of the following. 在“选择字段或组”对话框中,执行以下操作之一,指定将向用户显示哪些数据以及将哪些数据提交给外部数据源。

Specify that the data the user will see is the same data the user will submit 指定用户将看到的数据与用户将提交的数据相同

Click a field, and then click OK. 单击一个字段,然后单击确定。

Specify that the data the user will see is different from the data that the user will submit 指定用户将看到的数据与用户将提交的数据不同

Note: In this scenario, the data that the user will see is from one of the fields in the group, and the data that the user will submit is in another field in the same group. 注意:在这种情况下,用户将看到的数据来自组中的一个字段,而用户将提交的数据位于同一组中的另一个字段中。

Click a group, and then click OK. 单击一个组,然后单击确定。

In the Control Properties dialog box, click Select XPath Data Source button next to the Value box. 在“控件属性”对话框中,单击“值”框旁边的“选择XPath数据源”按钮。

In the Select a Field or Group dialog box, click a field that contains the data that the user will submit to the external data source, and then click OK. 在“选择字段或组”对话框中,单击包含用户将提交给外部数据源的数据的字段,然后单击“确定”。

In the Control Properties dialog box, click Select XPath Data Source button next to the Display name box. 在“控件属性”对话框中,单击“显示名称”框旁边的“选择XPath数据源”按钮。

In the Select a Field or Group dialog box, click a field that contains the data that will appear in the control, and then click OK. 在“选择字段或组”对话框中,单击包含将出现在控件中的数据的字段,然后单击“确定”。

If the field in the Display name box has values with similar display names, and you want to display only unique names, select the Show only entries with unique display names check box. 如果“显示名称”框中的字段具有与显示名称相似的值,并且您只想显示唯一名称,请选中“仅显示具有唯一显示名称的条目”复选框。

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

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