Hey, I’ve noticed after full regression testing that big XLSX files could cause troubles during tile watermarking process. The whole topic is about XLSX files from 1MB to 100MB in size.
That’s the code snippet which we’re using for watermarking process.
def main():
document_path = 'input.xlsx'
output_document_path = 'output.xlsx'
with gw.Watermarker(document_path) as watermarker:
font = gww.Font('Helvetica', 12.0)
watermark = gww.TextWatermark(f'{USER_EMAIL}\n{FILE_ID}\n{DISCLAIMER}', font)
watermark.foreground_color = gww.Color.gray
watermark.opacity = 0.4
watermark.rotate_angle = -45.0
watermark.text_alignment = gww.TextAlignment.CENTER
line_spacing = gww.MeasureValue()
line_spacing.measure_type = gww.TileMeasureType.POINTS
line_spacing.value = 200.0
watermark_spacing = gww.MeasureValue()
watermark_spacing.measure_type = gww.TileMeasureType.POINTS
watermark_spacing.value = 100.0
watermark.tile_options = gww.TileOptions()
watermark.tile_options.line_spacing = line_spacing
watermark.tile_options.watermark_spacing = watermark_spacing
watermark_options = gwos.SpreadsheetWatermarkShapeOptions()
watermark_options.is_locked = True
watermarker.add(watermark, options=watermark_options)
watermarker.save(output_document_path)
So, the worst thing which happend was that ~100MB XLSX file has never ended watermarking process and basically was stuck forever in it.
After research, I think the problem is basically in quantity of watermarks in XLSX file, so the only way I found to kinda resolve this problem is to increase font_size, line_spacing and watermark_spacing.
So, basically, the bigger file is (more columns and rows) the bigger spacings it requires.
So, I’ve increased it to the next values:
24.0 for font_size
500.0 for line_spacing
250.0 for watermark_spacing
The next issue that I’ve faced is that XLSX files are kinda “hard to use” after watermarking and it fully depends on computer power whether it could be redenred in desktop application or online viewers.
E.g. office-365-online just removes watermarks in big XLSX files in order to display the file.
Increasing values of font_size, line_spacing, watermark_spacing even more could help with rendering, but with increasing it more and more you can reach the point where tile watermarks become useless as there are huge spacings between them.
I understand that these two issues are not the most common things, but do you have any info / workarounds for such XLSX files rendering issues or maybe you’ve faced them during your testing?