Borders issue

Hello,

I am using the GridWeb component (v 2.0.1.2011) and I encounter an issue with borders. When I set a border to a cell like that, nothing happens :

Worksheet.Cells[1, 0].Style.BorderColor = Color.Black;
Worksheet.Cells[1, 0].Style.BorderWidth = new Unit("2px");
Worksheet.Cells[1, 0].Style.BorderStyle = BorderStyle.Solid;

But when I add these lines after the preceding three, the four borders appear arround the cell :

Worksheet.Cells[1, 0].Style.TopBorderStyle.BorderColor = Color.Black;
Worksheet.Cells[1, 0].Style.TopBorderStyle.BorderWidth = new Unit("2px");
Worksheet.Cells[1, 0].Style.TopBorderStyle.BorderStyle = BorderStyle.Solid;

I think it's a bug in the component.

Thanks

Hi,

I tested your code but could not find the issue.

Coud you try the attached version and let us know if it works fine.

Thank you.

Thanks.

I have the same problem with the new version. When I set borders like that, borders are set correctly :

Worksheet.Cells[1, 0].PutValue("Control Name");
Worksheet.Cells.SetColumnWidth(0, new Unit("100pt"));
Worksheet.Cells[1, 0].Style.Font.Bold = true;
Worksheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Center;
Worksheet.Cells[1, 0].Style.BackColor = Color.LightSkyBlue;
Worksheet.Cells[1, 0].Style.BorderColor = Color.Black;
Worksheet.Cells[1, 0].Style.BorderWidth = new Unit("2px");
Worksheet.Cells[1, 0].Style.BorderStyle = BorderStyle.Solid;

But when I add this line of code (Worksheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7)), borders disappear :

Worksheet.Cells[1, 0].PutValue("Control Name");
Worksheet.Cells.SetColumnWidth(0, new Unit("100pt"));
Worksheet.Cells[1, 0].Style.Font.Bold = true;
Worksheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7);
Worksheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Center;
Worksheet.Cells[1, 0].Style.BackColor = Color.LightSkyBlue;
Worksheet.Cells[1, 0].Style.BorderColor = Color.Black;
Worksheet.Cells[1, 0].Style.BorderWidth = new Unit("2px");
Worksheet.Cells[1, 0].Style.BorderStyle = BorderStyle.Solid;

The Worksheet object is a property defined like that :

private WebWorksheet Worksheet
{
get
{
return ctlInputGrid.WebWorksheets[ctlInputGrid.ActiveSheetIndex];
}
}

There also some strange behaviors with styles (the borders appears on all the cells of the grid, ...) when I use other combinations of styles for the cell.

Hi,

Well, we tested the following code with v2.0.1.17, but the issue does not appear at all. The line (Worksheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7)) dose not affect the style, whether we use it or not.

if (!IsPostBack)

{

WebWorksheet sheet = GridWeb1.WebWorksheets[0];

sheet.Cells[1, 0].PutValue("Control Name");

sheet.Cells.SetColumnWidth(0, new Unit("100pt"));

sheet.Cells[1, 0].Style.Font.Bold = true;

sheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7);

sheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Center;

sheet.Cells[1, 0].Style.BackColor = Color.LightSkyBlue;

sheet.Cells[1, 0].Style.BorderColor = Color.Black;

sheet.Cells[1, 0].Style.BorderWidth = new Unit("2px");

sheet.Cells[1, 0].Style.BorderStyle = BorderStyle.Solid;

}

Kindly, please create a sample project to show the issue and post it here. And, tell us your configurations/settings, like IE type, IIS, .NET Framework etc. We will check it soon.

Thank you.

Hi,

Thank you for considering Aspose.

I tested the following code with v2.0.1.17, but the issue does not appear. The line (Worksheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7)) does not affect the style.

if (!IsPostBack)

{

WebWorksheet sheet = GridWeb1.WebWorksheets[0];

sheet.Cells[1, 0].PutValue("Control Name");

sheet.Cells.SetColumnWidth(0, new Unit("100pt"));

sheet.Cells[1, 0].Style.Font.Bold = true;

sheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7);

sheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Center;

sheet.Cells[1, 0].Style.BackColor = Color.LightSkyBlue;

sheet.Cells[1, 0].Style.BorderColor = Color.Black;

sheet.Cells[1, 0].Style.BorderWidth = new Unit("2px");

sheet.Cells[1, 0].Style.BorderStyle = BorderStyle.Solid;

}

Kindly, create a sample project with the issue and post it here. And tell us your configurations like IE, IIS, .NET Framework etc. We will check it soon.

Thank You & Best Regards,

Thanks for your answers. I cannot post a sample project because I use the Grid in a SharePoint web part, but here is the code of my Web Part :

#region - Imports -

using System;

using System.Collections.Generic;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Web;

using System.Web.UI.WebControls.WebParts;


using Microsoft.SharePoint.WebControls;


using Aspose.Grid.Web;

using Aspose.Grid.Web.Data;


using System.Web.UI.WebControls;


#endregion - Imports -


namespace Test

{

public class StyleTestWebPart : WebPart

{


#region - Controls declaration -


protected GridWeb ctlInputGrid;


#endregion - Controls declaration -


#region - Properties -


///

/// Gets the collection of grid cells.

///

private WebCells GridCells

{

get

{

EnsureChildControls();

return ctlInputGrid.WebWorksheets[ctlInputGrid.ActiveSheetIndex].Cells;

}

}


///

/// Gets the the active worksheet.

///

private WebWorksheet Worksheet

{

get

{

EnsureChildControls();

return ctlInputGrid.WebWorksheets[ctlInputGrid.ActiveSheetIndex];

}

}


#endregion - Properties -


#region - Constructors -


public StyleTestWebPart()

{

Load += new EventHandler(StyleTestWebPart_Load);

}


#endregion - Constructors -


#region - Controls creation -


protected override void CreateChildControls()

{

ctlInputGrid = new GridWeb();

Controls.Add(ctlInputGrid);

ctlInputGrid.Width = new Unit("100%");

ctlInputGrid.Height = new Unit("600px");

ctlInputGrid.EnableAJAX = true;

ctlInputGrid.XhtmlMode = false;

ctlInputGrid.EnableClientFreeze = false;

ctlInputGrid.EnableClientColumnOperations = false;

ctlInputGrid.EnableClientRowOperations = false;

ctlInputGrid.EnableClientMergeOperations = false;

ctlInputGrid.EnableStyleDialogbox = false;

ctlInputGrid.ShowTabBar = false;

ctlInputGrid.ShowSaveButton = false;

ctlInputGrid.ShowSubmitButton = false;

ctlInputGrid.ShowUndoButton = false;

}


#endregion - Controls creation -


#region - Events -


void StyleTestWebPart_Load(object sender, EventArgs e)

{

EnsureChildControls();


if (!Page.IsPostBack)

{

Worksheet.Cells[1, 0].PutValue("Col1");

Worksheet.Cells.SetColumnWidth(0, new Unit("100pt"));

Worksheet.Cells[1, 0].Style.Font.Bold = true;

Worksheet.Cells[1, 0].Style.Font.Size = FontUnit.Point(7);

Worksheet.Cells[1, 0].Style.HorizontalAlign = HorizontalAlign.Center;

Worksheet.Cells[1, 0].Style.BackColor = Color.LightSkyBlue;

Worksheet.Cells[1, 0].Style.BorderColor = Color.Black;

Worksheet.Cells[1, 0].Style.BorderWidth = new Unit("2px");

Worksheet.Cells[1, 0].Style.BorderStyle = BorderStyle.Solid;


Worksheet.Cells[1, 1].PutValue("Col2");

Worksheet.Cells.SetColumnWidth(1, new Unit("80pt"));

Worksheet.Cells[1, 1].Style.Font.Bold = true;

Worksheet.Cells[1, 1].Style.Font.Size = FontUnit.Point(7);

Worksheet.Cells[1, 1].Style.HorizontalAlign = HorizontalAlign.Center;

Worksheet.Cells[1, 1].Style.BackColor = Color.LightSkyBlue;

}

}


#endregion - Events -


}

}

With this code, the cell “Col2” has borders even if I don’t set them. I think there is a problem with Styles but I can’t find where. I also have to mention that with the version 2.0.1.2011 of the Grid, everything was OK.

Hi,

Thanks for providing us further details and sharing your web part code.

We will look into your issue and get back to you soon.

Thank you.

Hi,

Thank you for considering Aspose.

Please try the attached latest version. We have fixed your mentioned issue. You may also update your code as following:

if (!IsPostBack)

{

Worksheet.Cells[1, 0].PutValue("Col1");

Worksheet.Cells.SetColumnWidth(0, new Unit("100pt"));

Aspose.Grid.Web.TableItemStyle style = new Aspose.Grid.Web.TableItemStyle();

style.Font.Bold = true;

style.Font.Size = FontUnit.Point(7);

style.HorizontalAlign = HorizontalAlign.Center;

style.BackColor = Color.LightSkyBlue;

style.BorderColor = Color.Black;

style.BorderWidth = new Unit("2px");

style.BorderStyle = BorderStyle.Solid;

Worksheet.Cells[1, 0].Style = style;


Worksheet.Cells[1, 1].PutValue("Col2");

Worksheet.Cells.SetColumnWidth(1, new Unit("80pt"));

style = new Aspose.Grid.Web.TableItemStyle();

style.Font.Bold = true;

style.Font.Size = FontUnit.Point(7);

style.HorizontalAlign = HorizontalAlign.Center;

style.BackColor = Color.LightSkyBlue;

Worksheet.Cells[1, 1].Style = style;

}

Thank You & Best Regards,

Thank you. It’s working far much better.

The issues you have found earlier (filed as 9972) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.