Hi Guys,
I have trouble with the styles of the borders.
When I use the following source code, the format of the borders is not changed.
var loadPath = @“C:\Users\MBerthold\Documents\TestArea\Aspose\Border\Border.xlsx”;
var savePath = @“C:\Users\MBerthold\Documents\TestArea\Aspose\Border\Result.xlsx”;
var myWorkbook = new Workbook(loadPath);
var mySheet = myWorkbook.Worksheets[myWorkbook.Worksheets.ActiveSheetIndex];
//Create Style
var style = myWorkbook.CreateStyle();
style.VerticalAlignment = TextAlignmentType.Center;
style.HorizontalAlignment = TextAlignmentType.Center;
style.Font.Color = Color.Green;
style.ShrinkToFit = true;
//Setting the bottom border color of the cell to red
style.Borders[BorderType.BottomBorder].Color = Color.Red;
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Dotted;
//Creating StyleFlag
var styleFlag = new StyleFlag();
styleFlag.HorizontalAlignment = true;
styleFlag.VerticalAlignment = true;
styleFlag.ShrinkToFit = true;
styleFlag.BottomBorder = true;
styleFlag.FontColor = true;
var row = mySheet.Cells.Rows[0];
row.ApplyStyle(style, styleFlag);
myWorkbook.Save(savePath);
What am I doing wrong?
I use the current Version of Aspose Cells (17.1).
I have followed the example below.
Apply Styles to Ranges in Workbooks|Documentation
My test document is Attached.
Thank you for your Support.
Hi there,
Hi,
Hi,
thank you guys.
Hi,
thanks for the current version, but I still see a problem.
If a border already exists and I change the first bottom border, I lost the left and right border (see screenshot).
Here my code:
var loadPath = @“C:\Users\MBerthold\Documents\TestArea\Aspose\Border\Border.xlsx”;
var savePath = @“C:\Users\MBerthold\Documents\TestArea\Aspose\Border\Result.xlsx”;
var myWorkbook = new Workbook(loadPath);
var mySheet = myWorkbook.Worksheets[myWorkbook.Worksheets.ActiveSheetIndex];
//Create Style
var style = myWorkbook.CreateStyle();
style.VerticalAlignment = TextAlignmentType.Center;
style.HorizontalAlignment = TextAlignmentType.Center;
style.Font.Color = Color.Green;
style.ShrinkToFit = true;
//Setting the bottom border color of the cell to red style.Borders[BorderType.BottomBorder].Color = Color.Red;
style.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Dotted;
//Creating StyleFlag
var styleFlag = new StyleFlag();
styleFlag.HorizontalAlignment = true;
styleFlag.VerticalAlignment = true;
styleFlag.ShrinkToFit = true;
styleFlag.BottomBorder = true;
styleFlag.FontColor = true;
var row = mySheet.Cells.Rows[0];
row.ApplyStyle(style, styleFlag);
myWorkbook.Save(savePath);
Attached my test document.
Thank you for your support.
Hi again,
Hi again,
The issues you have found earlier (filed as CELLSNET-45101) have been fixed in Aspose.Cells for .NET 17.2.0.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi,
Good Job, it work´s
Thank you
Hi again,