public string ButtonSelectedDate() { return this.selectDateDisplayTextBox.Text; }
protected void ExportActionButton_Click(object sender, EventArgs e) { try { List<string> header = new List<string>(); Dictionary<int, List<string>> body = new Dictionary<int, List<string>>(); List<string> footer = new List<string>(); DailySalesFigureModelResponseDto dailySales = new DailySalesFigureModelResponseDto(); Type type = dailySales.GetType(); PropertyInfo[] propertyInfoArray = type.GetProperties(); int count = 0; foreach (PropertyInfo propertyInfo in propertyInfoArray) { header.Add(propertyInfo.Name); } foreach (DailySalesFigureModelResponseDto dailySalesResponse in this.DataSource) { List<string> bodyRow = new List<string>(); foreach (PropertyInfo propertyInfo in propertyInfoArray) { string propertyValue = string.Empty; object value = propertyInfo.GetValue(dailySalesResponse, null); if (value != null) { propertyValue = value.ToString(); } bodyRow.Add(propertyValue); } body.Add(count, bodyRow); count++; } ExportableDataContent exportableDataContent = new ExportableDataContent(header, body, footer); TabularContent tabularContent = new TabularContent(); tabularContent = exportableDataContent.ToTabularFormat(); DefaultExporter exporte = new DefaultExporter(); exporte.Open(string.Empty); ExportLocation exportLocation = new ExportLocation("A", "2", "Sheet1"); exporte.WriteContent(tabularContent, exportLocation); string tempFolderPath = @"D:\"; ////Path.GetTempPath(); string fileName = this.posDetailReports.ButtonSelectedDate() + ".xlsx"; string excelFilePath = tempFolderPath + fileName; if (File.Exists(excelFilePath)) { File.Delete(excelFilePath); } exporte.Save(excelFilePath, ExportFormat.Excel); } catch (Exception ex) { } }
string fileName = this.posDetailReports.ButtonSelectedDate() + ".xlsx";
public string FileName { get { return fileName; } set { fileName = value; } }
usrControl.FileName = ButtonSelectedDate();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)