OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Column.OptimalWidth=true for only a range

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
fred_tomke
Newbie
Newbie


Joined: 03 Mar 2011
Posts: 1

PostPosted: Thu Mar 03, 2011 5:46 am    Post subject: Column.OptimalWidth=true for only a range Reply with quote

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.)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group