Can I add a custom header to exported Excel file?

落花浮王杯 提交于 2019-12-24 01:08:06

问题


I created a custom inquiry report in Visual Studio with the export to Excel button enabled. The page has a simple date filter.

All the values are exported correctly but we need to add the filter information to the document. This should be possible as Generic Inquiries print the parameters in the top of the sheet.

How can I either add the filter info to the document sheet or add the selected date to the filename?

Note: This is for an Acumatica custom inquiry page using the Acumatica Framework.


回答1:


To export both parameters and results from an inquiry screen to Excel, you should decorate your BLC with DashboardTypeAttribute or one of its successors, like TableAndChartDashboardTypeAttribute and TableDashboardTypeAttribute.

The InventorySummaryEnq BLC serving Inventory Summary screen (IN401000) is decorated with TableAndChartDashboardType to export parameters and results to Excel:

[PX.Objects.GL.TableAndChartDashboardType]
public class InventorySummaryEnq : PXGraph<InventorySummaryEnq>
{       
    ...
}   

Currently supported widget types (parameters of the DashboardType attribute):

0 - Table (default)
1 - Wiki article
2 - Task
6 - Table with owner and workgroup
7 - Calendar
8 - Generic Inquiry
20 - Chart



回答2:


You can pass your data to gridview, and set gridview.Caption as filter info, use convert gridview to excel function. See this http://www.codeproject.com/Tips/477436/Export-Gridview-Data-to-Excel-in-ASP-NET for details



来源:https://stackoverflow.com/questions/40617033/can-i-add-a-custom-header-to-exported-excel-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!