// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(AddingLineControl.class) + "DrawingObjects/";

//Instantiate a new Workbook.
Workbook workbook = new Workbook();

//Get the first worksheet in the book.
Worksheet worksheet = workbook.getWorksheets().get(0);

//Add a new line to the worksheet.
LineShape line1  = (LineShape)worksheet.getShapes().addShape(MsoDrawingType.LINE,5, 1,0,0, 0, 250);
line1.setHasLine(true);

//Set the line dash style
LineFormat shapeline = line1.getLine();
shapeline.setDashStyle(MsoLineDashStyle.SOLID);

//Set the placement.
line1.setPlacement(PlacementType.FREE_FLOATING);

//Add another line to the worksheet.
LineShape line2  = (LineShape) worksheet.getShapes().addShape(MsoDrawingType.LINE, 7, 1,0,0, 85, 250);
line2.setHasLine(true);

//Set the line dash style.
shapeline = line2.getLine();
shapeline.setDashStyle(MsoLineDashStyle.DASH_LONG_DASH);
shapeline.setWeight(4);

//Set the placement.
line2.setPlacement(PlacementType.FREE_FLOATING);

//Add the third line to the worksheet.
LineShape line3  = (LineShape)worksheet.getShapes().addShape(MsoDrawingType.LINE, 13, 1,0,0, 0, 250);
line3.setHasLine(true);

//Set the line dash style
shapeline = line1.getLine();
shapeline.setDashStyle(MsoLineDashStyle.SOLID);

//Set the placement.
line3.setPlacement(PlacementType.FREE_FLOATING);

//Save the excel file.
workbook.save(dataDir + "tstlines.xls");