I have to change border style to very light dotted border
Often referred to as “dotted” or “dotted border style” in Excel.
can you give me sample code for apply that border also i have highlighted that border in attachment
sc_border.zip (15.7 KB)
I have to change border style to very light dotted border
Often referred to as “dotted” or “dotted border style” in Excel.
can you give me sample code for apply that border also i have highlighted that border in attachment
sc_border.zip (15.7 KB)
To change the cell border style to a very light dotted border in Aspose.Cells for Java, you can use the setBorder
method of the Style
class. Here’s a complete solution with clear steps:
Cause: You want to apply a very light dotted border to a specific cell in an Excel workbook using Aspose.Cells for Java.
Solution: The following code snippet demonstrates how to create a new workbook, define a style with a light gray dotted border, and apply it to cell A1.
import com.aspose.cells.*;
public class ChangeCellBorderStyle {
public static void main(String[] args) throws Exception {
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
// Create a style for the cell
Style style = workbook.createStyle();
// Set the border style to dotted
style.setBorder(BorderType.TOP_BORDER, CellBorderType.DOTTED, Color.getLightGray());
style.setBorder(BorderType.BOTTOM_BORDER, CellBorderType.DOTTED, Color.getLightGray());
style.setBorder(BorderType.LEFT_BORDER, CellBorderType.DOTTED, Color.getLightGray());
style.setBorder(BorderType.RIGHT_BORDER, CellBorderType.DOTTED, Color.getLightGray());
// Apply the style to a specific cell (e.g., A1)
Cell cell = cells.get("A1");
cell.setStyle(style);
// Save the workbook
workbook.save("StyledWorkbook.xlsx");
}
}
Next Steps: You can run this code in your Java environment. Make sure you have the Aspose.Cells library included in your project. Adjust the cell reference and border color as needed for your specific requirements.
Closing Line: If you have any further questions or need additional assistance, feel free to ask!
i have used like below but it is now set first style or border style after none,
draw cell with square dot which is second place in border style after none
dayBorderStyleRange.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Dotted, defBorderColor);
@tejas.patel
Thank you for your feedback. You are welcome. If you have any questions, please feel free to contact us at any time.
Please try using enum option CellBorderType.Hair for your requirements. You may also refer to the code snippet in other thread post.