I am writing data to excel file. It only has two rows the file size is approx. 6 MB in XLSX format, if I choose the XLS format then it come down to 2.5 MB but that is also unacceptable.
Whereas if I just copy paste the data and save it using MS Excel, the size is just 169KB. The dataset only has two rows nothing big, following is the code I am using. It is also causing an exception at server side which gets logged in the event logs
Exception type: HttpException
Exception message: Server cannot append header after HTTP headers have been sent.
dataSheet.Cells.ImportCustomObjects(IncidentListDS, caption, True, 0, 0, IncidentListDS.Length, False, "dd/mm/yyyy", False)
dataSheet.AutoFitColumns()
Dim telePhoneColumnRange As Range = dataSheet.Cells.CreateRange(12, 1, True)
Dim _style As Aspose.Cells.Style = export.Styles(export.Styles.Add())
_style.HorizontalAlignment = TextAlignmentType.Right
Dim _styleFlag As StyleFlag = New StyleFlag()
_styleFlag.All = True
telePhoneColumnRange.ApplyStyle(_style, _styleFlag)
Dim _excelSaveOption As SaveOptions = New XlsSaveOptions()
_excelSaveOption.SaveFormat = SaveFormat.Excel97To2003
export.Save(Response, SESSION_INCIDENT_LIST_DS + ".xls", ContentDisposition.Attachment, _excelSaveOption)