From d3dd99c623a27b635cb24628aa94b1155ce47ddb Mon Sep 17 00:00:00 2001 From: brightside Date: Fri, 15 Aug 2025 04:27:56 +0000 Subject: [PATCH] update formatsummarytables to include new tables --- WeatherMacros.bas | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/WeatherMacros.bas b/WeatherMacros.bas index b563d6d..d0d84fb 100644 --- a/WeatherMacros.bas +++ b/WeatherMacros.bas @@ -176,11 +176,13 @@ Sub FormatSummaryTables() Dim rangeStart As Long, rangeEnd As Long Dim categories() As String Dim lastCol As Long + Dim headerText As String oDoc = ThisComponent oSheet = oDoc.Sheets.getByName("Summary") - categories = Array("Temp", "Wind", "Rel Humidity", "Avg Total Liquid Precipitation", "Rainy Days") + ' Updated categories list + categories = Array("Temp", "Wind Speed", "Wind Direction", "Rel Humidity", "Avg Total Liquid Precipitation", "Rainy Days", "Solar Radiation") outRow = 0 For i = LBound(categories) To UBound(categories) @@ -204,20 +206,28 @@ Sub FormatSummaryTables() cell = oSheet.getCellByPosition(j, outRow) cell.CharWeight = com.sun.star.awt.FontWeight.BOLD cell.IsTextWrapped = True - cell.CellBackColor = RGB(255, 173, 0) ' #FFAD00 orange + cell.CellBackColor = RGB(255, 173, 0) ' orange cell.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER - cell.VertJustify = com.sun.star.table.CellVertJustify.BOTTOM ' <-- changed + cell.VertJustify = com.sun.star.table.CellVertJustify.BOTTOM Next j ' Data rows formatting rangeStart = outRow + 1 - rangeEnd = outRow + 12 ' assuming 12 months data rows + rangeEnd = outRow + 12 ' 12 months For iRow = rangeStart To rangeEnd For j = 0 To lastCol cell = oSheet.getCellByPosition(j, iRow) cell.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER - ' No rounding here — NumberFormat is inherited from source + + ' === Optional: convert Solar Radiation from ly/day to kWh/m²/day === + If categories(i) = "Solar Radiation" And j > 0 Then + If cell.Type = com.sun.star.table.CellContentType.VALUE Then + cell.Value = cell.Value * 0.011622 + ' Optional: set number format to show 3 decimal places + cell.NumberFormat = oDoc.NumberFormats.queryKey("0.000", oDoc.getLocale(), True) + End If + End If Next j Next iRow