Calc sum column-widths

Is there a means of adding column-widths? Situation: I have several pages/tables --in Landscape orientation-- of differing column-widths. In order to fit these tables to their page, the total width of its columns is necessary, ideally in an automatic SUM shown below in a ‘dead’ cell. I could then simply adjust cell-widths to fit the SUM. Seems easy. Is it?
Any assistance in this regard would be appreciated!

As a workaround, you can choose menu File - Print Preview, and click the button Margins. There you can change visualy the columns width.

Page setup in Calc allows you to fit your print range to one page wide, automatically. Doesn’t this solve your real problem?

Apparently the author wants to avoid scaling the sheet.

Edit: This meant different scaling of different sheets, and, accordingly, different size of the font on the print.

Apparently?

I may miss something, yes, but due to my poor English, I do not fully understand what “fit these tables to their page” might mean. And I see no clarifying comments from the OP.

Yes, but with different widths of ranges of different sheets, the scale factor of the sheet will be different to fit everything onto the sheet. The author probably wants the scaling factor to be the same everywhere. To do this, you need to ensure the same width of the ranges on all sheets.

When I see someone reading author’s mind, I wonder what manufacturer created that someone’s crystal ball. Please do not try to argue - your opinion is just one possibility, and words like “apparently” and others, implying the opponent being clearly incorrect, look inappropriate without strong evidence. Thanks!

Well, below the author says I’m right. Without any crystal ball. It really seemed obvious to me. What good is it when numbers and letters jump on paper: small big again small (on different sheets of paper, of course)? No, you can, of course, scale, but with the same coefficients on all sheets. It looks like it’s a matter of aesthetics…

Of spreadsheet functions there is only the CELL function’s "WIDTH" argument that makes it return a pretty much useless value of “the number of zeros (0) that fit into the column in the default text with the default size.”, where that default font size is an invention of Excel (or Lotus) of an imaginary unit. See also online help.

For calculations in actual length units you would have to write a macro that obtains column width properties.

1 Like

After finding out how many zeros fit into a page width and if this unit turns out to be precisely enough, zeroes should be just as good or bad as any other unit. I like that approach. This unit seems to be based on zeroes of cell style “Default”. If I change the font size of that stlye, CELL(“width”;A1) adjusts accordingly. This is one of these things that requires hard recalculation [Ctrl+Shift+F9] or a content change in the referenced cell. Changing the column width does not trigger any recalculation.
If your page setup requires A:F being within one page width and your page width takes 100 zeroes, you get a “warning cell” like this
=CELL(“width”;A1)+CELL(“width”;B1)+CELL(“width”;C1)+CELL(“width”;D1)+CELL(“width”;E1)+CELL(“width”;F1)+STYLE(IF(CURRENT()>100;“Warn”))

This macro will place the width of the current cell or of continuous selected cells in the cell of your choice (your “dead” cell). You can put it on your toolbar with Tools-Customize-Toolbars(Tab)-Macros(Category)-RangeWidth once you have placed the macro in your document’s macros.

If you aren’t familiar with adding macros you should seek a fuller description, but in short it is Tools-Macros-Organize Macros-BASIC-Organizer…(Button) then highlight your document, click New… just use Module1 so OK. Then exit out of all of that and use Tools-Macros-Edit Macros… then double click on your document’s name, double click on Standard, double click on Module1, then paste the macro in at the right. (This is not the shortest, but the clearest route for me.)

Sub RangeWidth()
	Dim Doc As Object
	Dim ActiveCells As Object
	Dim Selection As Object
	Dim Width As Long
	Dim Value As String
	Const UnitsPerInch As Integer = 2540
	Const OutputAddress As String = "$A$1"
	
	Selection = ThisComponent.currentSelection
	If Selection.supportsService("com.sun.star.sheet.SheetCell") Or _
		Selection.supportsService("com.sun.star.sheet.SheetCellRange") Then
		Width = Selection.Size.Width
		Value = "Width of current cell or selection is: " & Width & " (" & Round(Width / UnitsPerInch, 2) & "'')"
		'MsgBox Value
		ThisComponent.getCurrentController.ActiveSheet.getCellRangeByName(OutputAddress).String = Value
	End If

End Sub 'RangeWidth

Personally, I think the MsgBox option makes more sense, so just uncomment it and comment out the cell setting line if that makes more sense for you, too. (Use the ’ to comment out, etc.)

This is confusing, the size is not measured in points but 1/100 mm, see also LibreOffice: SheetCellRange Service Reference. (the conversion to inch would be 2540).

If resorting to user code I would prefer a function.
You may check the raw code contained in the attached example.
(Always check alien code for the absence of malign parts in advance of permitting executpon.)
disask71715.ods (12.5 KB)

I knew there would be a little confusion using “points” since that is a typographic measurement, but it didn’t sound like the OP would be concerned; I just wanted to be clear it was not pixels. I’ll dream up something other than TensOfMicrometers and change it.

As an aside, @erAck, if you quote me and correct a detail, perhaps you could include in the quote that I had a comment saying the detail was not official. I mean, we can’t all know the metric system…it’s only used in 200 countries or so.

:joy: yeah right, metric system is unfortunate.

The zero is the essence of the metric system, isn’t it?

But there are zero deniers! Even AD!
And they need to be clever guys. How would they understand otherwise that AM is before, but AD is after, that 12:30 AM is one hour earlier than 1:30 AM, .
I always look at them standing in awe.
.

1 Like

AM is ANTEmeridian or before the meridian
AD is ANNODomini or after the Death
-and -
12:30 AM (just after midday) is Thirteen hours before 1:30 AM (just after midnight)
For the record, points are the vertical size of the Capitals of the typographic example with 72 points being equal to 1 inch. The width is something totally different - usually referred to as “tracking” and can only be fixed if the font example is non-proportional.

It’s 30 minutes after midnight.

Sadly mistaken that’s 00:30