View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Aniyan_Remo Aniyan_Remo is offline
external usenet poster
 
Posts: 1
Default Exporting data from Crystal Report to Excel - Need soln

Hi,
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 in C# program for
showing border lines, the following is the code I'm using in the Web
Application (C# language):

using Excel;
string workbookPath = "c:/SomeWorkBook.xls";
ExportOptions export = new ExportOptions();
DiskFileDestinationOptions ex = new DiskFileDestinationOptions();
ex.DiskFileName=workbookpath;
export.DestinationOptions = ex;
ReportDocument.Export();
Excel.Application excelApp = new Excel.ApplicationClass();
excelApp.Visible = true;
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0,
true, false, false);
Excel.Sheets excelSheets = excelWorkbook.Worksheets;
string currentSheet = "Sheet1";
Excel.Worksheet excelWorksheet =
(Excel.Worksheet)excelSheets.get_Item(currentSheet );
Excel.Range cell = excelWorksheet.UsedRange;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeT op ).LineStyle
=Excel.XlLineStyle.xlContinuous;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeB ottom ).LineStyle
=Excel.XlLineStyle.xlContinuous;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeR ight ).LineStyle
=Excel.XlLineStyle.xlContinuous;
cell.Borders.get_Item(Excel.XlBordersIndex.xlEdgeL eft ).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 into
the terminal. So whenever I export data, that many times the Excel
Application are running in the process.

How to solve this problem? Pls help me out...