Exporting data from Crystal Report to Excel
I'm exporting data from Crystal Report to Excel. When I export I'm not able to see the borders, hence I'm using Excel namespace for showing border lines, the following is the code I'm using in the Web Application:
using Excel;
string workbookPath = "c:/SomeWorkBook.xls"; DiskFileDestinationOptions ex = new DiskFileDestinationOptions(); Excel.Application excelApp =
ExportOptions export = new ExportOptions();
ex.DiskFileName=workbookpath;
export.DestinationOptions = ex;
ReportDocument.Export();
excelApp.Visible =
true;// Makes Excel visible to the user.// The following code opens an existing workbookExcel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "",false, Excel.XlPlatform.xlWindows, "",true,false, 0,true,false,false);// The following gets the Worksheets collectionExcel.Sheets excelSheets = excelWorkbook.Worksheets;
// The following gets Sheet1 for editingstring currentSheet = "Sheet1";Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
Excel.Range cell = excelWorksheet.UsedRange;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop ).LineStyle =Excel.XlLineStyle.xlContinuous;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom ).LineStyle =Excel.XlLineStyle.xlContinuous;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeRight ).LineStyle =Excel.XlLineStyle.xlContinuous;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft ).LineStyle =Excel.XlLineStyle.xlContinuous;
excelWorkbook.Save();
excelWorkbook.Close(Type.Missing,workbookpath,Type.Missing);
export.DestinationOptions = ex;
excelWorkbook = null;
excelSheets = null;
excelApp = null;
When I use the above code, the Excel application is running in the background (I'm able to see the process running for that in the Task Manager) under IUSR_<servername> and as well as under current user who as logged in. So whenever I export data, that many times the Excel Application are running in the process.
How to solve this problem?
Thanks & Regards.
Remo.

