ClearRange()

Hi,

I am trying to replace Actuate Code with Aspose. Do we have any equivalent of the Actuate method ClearRange() in Aspose ?

http://developer.actuate.com/be/documentation/R11SP1/ese/help/pess/wwhelp/wwhimpl/common/html/wwhelp.htm#href=Worksheet-elements.04.32.html&single=true

Thanks,

Aspose Evaluation

Hi,

Thanks for considering Aspose.Cells.

Yes, we have following methods inside Worksheet.getCells() object that you can use to clear contents, formats or everything.

Class Cells

java.lang.Object
com.aspose.cells.Cells

void clearContents(CellArea range)
Clears contents of a range.

void clearContents(int startRow, int startColumn, int endRow, int endColumn
Clears contents of a range.

void clearFormats(CellArea range)
Clears formatting of a range.

void clearFormats(int startRow, int startColumn, int endRow, int endColumn)
Clears formatting of a range.

void clearRange(CellArea range)
Clears contents and formatting of a range.

void clearRange(int startRow, int startColumn, int endRow, int endColumn)
Clears contents and formatting of a range.

Hi Faiz,

Thanks for a reply, we require one more input on the same, how can i clear the formula from the cell.

Thanks,

AsposeEvaluation

Hi,

Thanks for your posting and considering Aspose.Cells.

clearContents() method will remove the formulas too. Similarly, clearRange() method will remove both formulas and formatting.

Please see the following code that illustrates how to remove the contents in a range A1:C10.

Java


Workbook workbook = new Workbook(“source.xlsx”);

Worksheet worksheet = workbook.getWorksheets().get(0);


CellArea area = CellArea.createCellArea(“A1”, “C10”);

worksheet.getCells().clearContents(area);


workbook.save(“output.xlsx”);


I think this was happening because I used ClearRange insted of ClearContents. After switching to ClearContents, this wasnt an issue

Hi Jayesh,


It is good to know that you are able to resolve the problem by switching to ClearContents method. Please feel free to contact us back in case you need our further assistance with Aspose APIs.