Shapes not being applied on top of Excel file

Howdy,

We are using Aspose.Cells for adding shapes (i.e., watermarks) on top of Excel files and noticing an issue with them not being applied to a sheet.

In particular, there seems to be a bug with how cell data is determined when using the getMaxDataRow() and getMaxDataColumn() methods.

Have done some testing with a basic file and if only text boxes, shapes with text, or images are used then no watermark appears. The moment text is entered into any cell (including hidden text), however, the watermark shows up. The expected behavior is that the watermark should appear regardless of if data is within a cell or a shape.

Have attached test Excel file and screenshots and please let me know if you need more info.

Thanks for the help!

test-spreadsheet.zip (22.5 KB)
with-watermark.jpg (87.3 KB)
without-watermark.jpg (73.4 KB)

@steve123abc
Please use Cells.getMaxDisplayRange() method :

getMaxDataRow/Column only returns max row and colum of the cell which contains data.

@steve123abc
By using the following sample code for testing, we can obtain the correct results. Please refer to the attachment (25.1 KB).

The sample code as follows:

Workbook workbook = new Workbook(filePath + "test-spreadsheet.xlsx");

int sheetCount = workbook.getWorksheets().getCount();
for (int i = 0; i < sheetCount; i++)
{
	Worksheet sheet  = workbook.getWorksheets().get(i);
	int maxDataRow = sheet.getCells().getMaxDataRow();
	int maxDataCol = sheet.getCells().getMaxDataColumn();
    // Add Watermark
    Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1,
    "CONFIDENTIAL", "Arial Black", 50, false, true
    , maxDataRow, 8, maxDataCol, 1, 130, 800);

    wordart.setRotationAngle(315);
    
    // Get the fill format of the word art
    FillFormat wordArtFormat = wordart.getFill();

    // Set the transparency
    wordArtFormat.setTransparency(0.9);

}

// Save the file
workbook.save(filePath + "out_java.xlsx");

If you still cannot obtain the correct results, please share your test code and we will check it soon.

thanks for quick response!

will give those a go and see what happens

@steve123abc,

Sure, please take your time to test the sample code segment (shared). Hopefully, it will work for the purpose.