Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Sep 22, 2022 10:05 am

Hi all !

I've just updated the SPIRE.xls to the latest version. Do you have problems using borders ?


This is my code:

Code: Select all
CellRange range = sheet.Range["A2:L2"];

range.Borders.LineStyle = LineStyleType.Thin;

range.Borders[BordersLineType.EdgeTop].LineStyle = LineStyleType.None;
range.Borders[BordersLineType.EdgeLeft].LineStyle = LineStyleType.None;
range.Borders[BordersLineType.EdgeRight].LineStyle = LineStyleType.None;
range.Borders[BordersLineType.DiagonalDown].LineStyle = LineStyleType.None;
range.Borders[BordersLineType.DiagonalUp].LineStyle = LineStyleType.None;


But I have a strange result ... I have all the cells with borders, but is the opposite selection of my code (see attached pic).


Can anybody help me ?

LUCA
Attachments
result.jpg
result.jpg (277.6 KiB) Viewed 471 times
User avatar

luca.demori
 
Posts: 10
Joined: Fri Mar 23, 2018 1:55 pm

Fri Sep 23, 2022 5:52 am

Hello,

Thanks for your message.
Based on your code snippet, I noticed that you want to remove the borders for the merged cell. I simulated an excel file and used the below code to test with our Spire.XLS Pack(Hotfix) Version:12.8.1. The output is correct. Thus, you can test this code on your side. If your problem persists after the test, in order to facilitate our further investigation, please provide us with your test documents. You can attach it here or send it via email(support@e-iceblue.com).
Code: Select all
            //Create a workbook
            Workbook workbook = new Workbook();
            //Load the document from disk
            workbook.LoadFromFile(@"DataSorting1.xls");
            //Get the first worksheet
            Worksheet sheet = workbook.Worksheets[0];
            CellRange range = sheet.Range["A2:E2"];
            range.BorderAround(LineStyleType.None);
            range.Borders[BordersLineType.DiagonalDown].LineStyle = LineStyleType.None;
            range.Borders[BordersLineType.DiagonalUp].LineStyle = LineStyleType.None;
            string result = "SetBorder_result.xlsx";
            //Save the document
            workbook.SaveToFile(result, ExcelVersion.Version2010);


Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.XLS