Hello Team,
If I save workbook with .xlsx then gridlines are still visible. Please can you suggest what is wrong in this code ?
import com.aspose.cells.Chart;
import com.aspose.cells.ChartType;
import com.aspose.cells.CrossType;
import com.aspose.cells.FormattingType;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
public class AsposeCellTestGridlines {
public static void main(String args []) throws Exception {
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Adding a new worksheet to the Excel object
int sheetIndex = workbook.getWorksheets().add();
//Obtaining the reference of the newly added worksheet by passing its sheet index
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
//Adding a sample value to "A1" cell
worksheet.getCells().get("A1").putValue(50);
//Adding a sample value to "A2" cell
worksheet.getCells().get("A2").putValue(100);
//Adding a sample value to "A3" cell
worksheet.getCells().get("A3").putValue(150);
//Adding a sample value to "B1" cell
worksheet.getCells().get("B1").putValue(4);
//Adding a sample value to "B2" cell
worksheet.getCells().get("B2").putValue(20);
//Adding a sample value to "B3" cell
worksheet.getCells().get("B3").putValue(50);
//Adding a chart to the worksheet
int chartIndex = worksheet.getCharts().add(ChartType.COLUMN, 5, 0, 25, 5);
//Accessing the instance of the newly added chart
Chart chart = worksheet.getCharts().get(chartIndex);
//Adding NSeries (chart data source) to the chart ranging from "A1" cell to "B3"
chart.getNSeries().add("A1:B3", true);
chart.getValueAxis().getMajorGridLines().setVisible(false);
chart.getValueAxis().getMajorGridLines().setFormattingType(FormattingType.NONE);
chart.getCategoryAxis().getMajorGridLines().setVisible(false);
//Set the max value of value axis
chart.getValueAxis().setMaxValue(200);
//Set the min value of value axis
chart.getValueAxis().setMinValue(0);
//Set the major unit
chart.getValueAxis().setMajorUnit(25);
//Category(X) axis crosses at the maxinum value.
chart.getValueAxis().setCrossType(CrossType.MAXIMUM);
//Set he number of categories or series between tick-mark labels.
chart.getCategoryAxis().setTickLabelSpacing(2);
//Saving the Excel file
workbook.save("C:\\book1.xlsx");
}
}