i have Revit Plugin that is made of a ribbon solution that calls a functio to generate a report using ClosedXML.Report. When i run the code, there are no errors and the the Excel File is generated properly with the correct data in it. However, my Revit program hangs. If i comment out the "template.Generate" line in my code, Revit does not hang. I am not sure how to debug it.
Here is my code:
public void CreateReport()
{
List<order> orders1 = new List<order>()
{
new order() {
OrderNo = 1001,
SaleDate = new DateTime(2024, 3, 15),
ShipDate = new DateTime(2024, 3, 20),
ShipToAddr1 = "123 Main St",
ShipToAddr2 = "Apt 101",
PaymentMethod = "Credit",
ItemsTotal = 50.0,
TaxRate = 0.1,
AmountPaid = 55.0
},
new order() {
OrderNo = 1002,
SaleDate = new DateTime(2024, 3, 18),
ShipDate = new DateTime(2024, 3, 23),
ShipToAddr1 = "456 Elm St",
ShipToAddr2 = "Suite 200",
PaymentMethod = "Cash",
ItemsTotal = 75.0,
TaxRate = 0.05,
AmountPaid = 78.75
}
};
// Specify INput and output file names
const string templateFile = @"Z:\BIM\405_Industrial\2024_2_26\Templates\customerTest.xlsm";
string outputFile = @"Z:\BIM\405_Industrial\2024_2_26\Output\customerTest.xlsm";
// Add Data to cust object
CustomerTest cust = new CustomerTest(orders1);
// Create a new ClosedXML.Report object
var template = new XLTemplate(templateFile);
// Add the data to the template Object
template.AddVariable(cust);
// Generate the template into the excel workbook
template.Generate();
//Save the Workbook
template.Workbook.SaveAs(outputFile);
} // CreateReport
Any ideas on how to resolve this?