Hi,I am using INfragistic EXCel to create a Excel file in server folder[Service layer]. It creates a file only if datatable has very few records. if dataTable has more records than it throws a Exception "Stream does not support reading". Please let me know the issue and resolution.Even i have mention the Format for columns its not applying.I have attached the code file along with the mail. Could you please look into my code and update the same.Thanks
Anil
This sounds like something that was fixed already. What version are you using and do you have the latest service release installed?
Also, you can work around this by passing a MemoryStream to the Workbook.Save method. When it returns, write that stream to the file.
Hi ,Thanks for your Reply.I am using LOB of SilverLight Netadvantage. Version is 10.3.20103.1006.Now i am writing into MemoryStream and then writing back to File. But still Format is not applied.I have attached the code below. please check and let me know the issue and resolution. string path = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + @"Export\" + "ABC.xls"; FileStream file1 = new FileStream(path, FileMode.Create, FileAccess.Write); MemoryStream memStream = new MemoryStream(); #region "Create a file using Stream" try { WorkbookFormat workbookFormat = WorkbookFormat.Excel97To2003; // create an Excel workbook in the specified format Workbook dataWorkbook = new Workbook(workbookFormat); // create the Excel worksheet to receive the export data Worksheet worksheet = dataWorkbook.Worksheets.Add(worksheetName); // freeze header row worksheet.DisplayOptions.PanesAreFrozen = true; worksheet.DisplayOptions.FrozenPaneSettings.FrozenRows = 1; #region "Header Row" worksheet.DefaultColumnWidth = 5000; int currentColumn = 0; foreach (DataColumn column in result.Columns) { string format = GetFormatForColumn(column.ColumnName); worksheet.Rows[0].CellFormat.FormatString = format; this.SetCellValue(worksheet.Rows[0].Cells[currentColumn], column.ColumnName, null); currentColumn++; } #endregion int currentRow = 1; foreach (DataRow row in result.Rows) { int currentCell = 0; foreach (DataColumn col in result.Columns) { this.SetCellValue(worksheet.Rows[currentRow].Cells[currentCell], row[col.ColumnName], col.DataType); currentCell++; } currentRow++; } dataWorkbook.Save(memStream); byte[] data = memStream.ToArray(); file1.Write(data, 0, data.Length); file1.Close(); } catch (Exception ex) { string msg = ex.InnerException.Message; } #endregion
Thanks
Anil Kumar