Can I add a custom header to exported Excel file?

2019-07-21 10:44发布

问题:

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



标签: acumatica