Show gridlines when export from crystal report to excel RRS feed

  • Question

  • Hi,

    I m working on crystal reports 10.5. I m exporting data from CR to excel. Issue is, grid lines between the columns are missing after data is exported to excel. Is there any way to show the data with gridlines in excel? Also, is there any possiblity of changing column width in excel after data is exported from CR?


    Balaji Gurunathan


    Balaji Gurunathan
    Wednesday, July 20, 2011 12:11 PM

All replies

  • Hi Balaji,

    Use this:

    CrystalDecisions.Shared.ExcelFormatOptions XLSFormatOptions = new CrystalDecisions.Shared.ExcelFormatOptions();

    XLSFormatOptions.ShowGridLines = true;

    It's in CR 2008 but not sure if it's available in CR Basic for VS 2008. Use the object browser after including CrystalDecisions.Shared in your references. If it's there then it should work.


    Don Williams
    Wednesday, July 20, 2011 1:55 PM
  • Hi Don,

    Thanks for your reply.

    I checked in CR 2008 but it's not available. Is there any other way to do this?


    Balaji Gurunathan
    Thursday, July 21, 2011 5:08 AM
  • Hi Balaji,

    Sorry, if you did add CrystalDecisions.Shared to your project and still don't see it then you are using CR Basic for VS 2008 in your app, if you do have a full build of Crystal Reports 2008 then change your assemblies to version 12.x.x.x and then the function will be there. CR Basic does have a limited set of API's, to get the full functionality then you have to upgrade either to CR 2008 or VS 2010 and CR for VS 2010 which now includes almost everything and few more features.

    If you don't then other possible options would be to use Excel SDK to add the grids in the XLS file if that's possible or if there is a XLS SDK you can use.


    Don Williams
    Thursday, July 21, 2011 2:49 PM
  • Do you try



    CrystalDecisions.Shared.ExportOptions CrExportOptions ;
     CrExportOptions.ExportFormatType = ExportFormatType.ExcelRecord;     //This format will visible the grid lines   


    To change the width of cell



     Microsoft.Office.Interop.Excel.Application xlApp;
     Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
     Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
     object misValue = System.Reflection.Missing.Value;
     Microsoft.Office.Interop.Excel.Range range;
     xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();
     xlWorkBook = xlApp.Workbooks.Open("Path of excel file", 0, false, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
     xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item("Sheet1");
     xlWorkSheet.Cells[2, 1] = "Date";//Name You want to give to specific cell
     range = xlWorkSheet.get_Range("a2", "i2"); range.Font.Bold = true; //Set the font for column in that range! range.ColumnWidth=8.29; //Set the width for column in that range! xlWorkSheet.Cells.RowHeight = 12; xlWorkBook.Close(true, misValue, misValue); xlApp.Quit();

    You have to add COM refrence to Microsft .Office.Core

    • Proposed as answer by SAPDon Friday, July 22, 2011 2:54 PM
    Friday, July 22, 2011 7:17 AM