Trouble using UNOIDL library in C# on Windows 11 for LibreOffice Calc automation

Greetings everyone,

I’m currently using C# with the UNOIDL library on Windows 11. I’ve populated a Calc file from C# code; now I want to select the print area for the entire populated region. I’ve tried the following instructions found online:

// Select the print area
XPrintAreasSupplier xPrintAreasSupplier = (XPrintAreasSupplier)xSpreadsheet;
XPrintAreas xPrintAreas = xPrintAreasSupplier.getPrintAreas();
xPrintAreas.addPrintArea(0, 0, 10, 10, 0);

However, Visual Studio does not recognize XPrintAreasSupplier and addPrintArea. How can I resolve this issue?

Thank you all.

… not sure where you have your code from, but neither the interface XPrintAreasSupplier nor a function addPrintArea exists in UNOIDL as far as I understand the documentation.

Try this:

CellRangeAddress[] xPrintAreas = new CellRangeAddress[1];
xPrintAreas[0] = new CellRangeAddress();
xPrintAreas[0].Sheet = 0;
xPrintAreas[0].StartColumn = 0;
xPrintAreas[0].StartRow = 0;
xPrintAreas[0].EndColumn = 10;
xPrintAreas[0].EndRow = 10;
( (XPrintAreas) xSpreadsheet).setPrintAreas(xPrintAreas);

Good luck,


Thanks a lot, this was helpfull :blush:.