fred_tomke Newbie

Joined: 03 Mar 2011 Posts: 1
|
Posted: Thu Mar 03, 2011 5:46 am Post subject: Column.OptimalWidth=true for only a range |
|
|
Hello,
I studied the postings concerning the OptimalWidth property of a column but I still didn't find a solution for my question. All of the topics seem to have the general recalculation of the optimal column width for the whole column. But I want to shrink the recalculation to a certain range. It works very well for me in Excel, so I thought that it should work in Calc, too.
It is necessary for me to recalculate the optimal column width for a certain range because in the first line there is a headline so the Column.OptimalWidth = true would cause the first column to be widened to the width of the headline. To avoid that I want to shrink the recalculation area to a certain range. As I already told, it works for me in Excel. But the same workflow seems not to work in Calc: it seems that the recalculation is made by the whole column instead of the column of the given range.
It must work in principal because I can select the range by hand and call the command Format > Columns > Optimal width and then the optimal width is calculated by the selected area. So I want to do it programmatically.
Does anybody have experiences in that?
| Code: | object oRange = OOCalc.Do(oSheet, "GetCellRangeByPosition", 0, 4, 4, 12);
object oCols = OOCalc.Get(oRange, "Columns");
object oCol = OOCalc.Do(oCols, "GetByIndex", 0);
OOCalc.Set(oCol, "OptimalWidth", true); |
Thanks und regards,
Fred
(Note: the presented code is copied and compressed from my C# project to demonstrate the principal existing workflow. I created an own class to access Calc using late binding the COM-object.) |
|