Free Support Forum - aspose.com

Gridlines disappear in excel after exporttoExcel

I am saving data from the grid and after opening excel, the gridlines are non-existant. Is there a solution?
This message was posted using Aspose.Live 2 Forum

Hi,

Do you import data from data grid to Excel worksheet and save the file with Aspose.Cells API,

If this is the case, the gridlines would not be visible by default, this behavior is same as MS Excel. If you want to show the gridlines, you may use Worksheet.IsGridlinesVisible to set it to true before saving the Excel file.

If you are using Aspose.Cells Grid control (e.g Aspose.Cells.GridWeb), you may set borders around your data in the cells for your need and then save the Excel file from the the grid. See the demo for reference:
http://www.aspose.com/demos/.net-components/aspose.cells/csharp/grid/common/create-invoice.aspx

Thank you.

I am using GridDesktop

gridDesktop1.ExportExcelFile(filename);

and the Worksheet IsGridlinesVisible doesn't exist on the worksheet that I can find.

Basic function, I am using GridDesktop and adding data to the grid in various ways using a datatable being one.

Then calling the exportexcelfile function to save. When I open the excel file the gridlines are not showing, however when I view the grid in my program, the gridlines show there.

Any ideas?

this is a sample of the output.

Hi,

If you are using Aspose.Cells.GridDesktop, the Worksheet.IsGridlinesVisible attribute is not available.
Now we understand you and found the issue after an initial test. We will figure it out soon. Your issue has been logged into our issue tracking system with an issue id: CELLSNET-14935.

By the way, the gridlines in MS Excel are not printed by default. However, if you want to show the gridlines for the exported data from GridDesktop to Excel, you may set borders around your data using Aspose.Cell.GridDesktop’s right click menu (option - Format Cells… dialog box) or you may set it by using the API of the control, for reference, see the sample code in FormBorders before saving/exporting the Excel file.

Thank you.

I have tried creatinga style function for my worksheets. But the export still saves with no gridlines.

Here is my style function:

private void SetStyle(Worksheet sheet)

{

CellRange sr = new CellRange();

sr.StartRow = 0;

sr.EndRow = 100;

sr.StartColumn = 0;

sr.EndColumn = 100;

Style sty1 = new Style(gridDesktop1);

sty1.SetBorderColor(BorderType.Bottom, Color.Black);

sty1.SetBorderColor(BorderType.Left, Color.Black);

sheet.SetStyle(sr,sty1);

}

Hi,

Please change your code to:

private void SetStyle(Worksheet sheet)

{

CellRange sr = new CellRange();

sr.StartRow = 0;

sr.EndRow = 100;

sr.StartColumn = 0;

sr.EndColumn = 100;

Style sty1 = new Style(gridDesktop1);

sty1.SetBorderLine(BorderType.Left, BorderLineType.Thin);
sty1.SetBorderColor(BorderType.Left, System.Drawing.Color.Black);
sty1.SetBorderLine(BorderType.Right, BorderLineType.Thin);
sty1.SetBorderColor(BorderType.Right, System.Drawing.Color.Black);
sty1.SetBorderLine(BorderType.Top, BorderLineType.Thin);
sty1.SetBorderColor(BorderType.Top, System.Drawing.Color.Black);
sty1.SetBorderLine(BorderType.Bottom, BorderLineType.Thin);
sty1.SetBorderColor(BorderType.Bottom, System.Drawing.Color.Black);

sheet.SetStyle(sr,sty1);

}

Thank you.

Thank you much. That works great!