diff --git a/CHANGELOG.md b/CHANGELOG.md index b52980cf9..373459c55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - macros: added remove extra spaces in document macro sample - macros: added the Sum of highlighted cells macro sample - macros: added change font family and size in presentations macro sample +- macros: added hide unhide rows or columns in spreadsheet macro sample ## 6.3.0 - docspace oauth api: added a new section diff --git a/site/assets/images/plugins/hide-unhide-rows-columns.dark.png b/site/assets/images/plugins/hide-unhide-rows-columns.dark.png new file mode 100644 index 000000000..8db03204e Binary files /dev/null and b/site/assets/images/plugins/hide-unhide-rows-columns.dark.png differ diff --git a/site/assets/images/plugins/hide-unhide-rows-columns.png b/site/assets/images/plugins/hide-unhide-rows-columns.png new file mode 100644 index 000000000..534cbaad7 Binary files /dev/null and b/site/assets/images/plugins/hide-unhide-rows-columns.png differ diff --git a/site/pages/Docs/Plugin and Macros/Macros/Samples/Hide or unhide rows and columns/index.md b/site/pages/Docs/Plugin and Macros/Macros/Samples/Hide or unhide rows and columns/index.md new file mode 100644 index 000000000..80a44bd72 --- /dev/null +++ b/site/pages/Docs/Plugin and Macros/Macros/Samples/Hide or unhide rows and columns/index.md @@ -0,0 +1,51 @@ +--- +order: +--- + +## Description + +Hides or unhides the specified rows and/or columns in the spreadsheet. + + + + + +```ts +(function() +{ + const sheet = Api.GetActiveSheet() + const range = sheet.GetRange("A1:M1") + const rowsToHide = [5, 8, 9, 12, 14, 16, 21, 22, 31, 32, 33] + const columnsToHide = [2,4,5,7,8,10,11,13,14,16] + const hidden = sheet.GetRows(rowsToHide[0]).GetHidden() + hideUnhideDetails(hidden) + // Unhide if hidden, Hide if unhidden + function hideUnhideDetails(hidden) { + rowsToHide.forEach(row => { + sheet.GetRows(row).SetHidden(!hidden) + }) + columnsToHide.forEach(column => { + range.GetCols(column).SetHidden(!hidden) + }) + } +})(); +``` + +Methods used: GetActiveSheet, GetRange, GetRows, GetHidden, GetCols, SetHidden + +## Reference Microsoft VBA macro code + + + +```vb +Sub HideUnhide() + Rows("5:10").Hidden = Not Rows("5:10").Hidden + Columns("B:D").Hidden = Not Columns("B:D").Hidden +End Sub +``` + +## Result + + + +![Hide or unhide rows and columns](/assets/images/plugins/hide-unhide-rows-columns.png) diff --git a/site/pages/Docs/Plugin and Macros/Macros/Samples/index.md b/site/pages/Docs/Plugin and Macros/Macros/Samples/index.md index c2dffe38f..a61e81237 100644 --- a/site/pages/Docs/Plugin and Macros/Macros/Samples/index.md +++ b/site/pages/Docs/Plugin and Macros/Macros/Samples/index.md @@ -142,6 +142,12 @@ In this example we are changing the font family and/or size in the presentation. [More](Change%20font%20family%20and%20size/index.md) +## Hide or unhide rows and columns + +In this example we are hiding or unhiding specified rows and/or columns in the spreadsheet. + +[More](Hide%20or%20unhide%20rows%20and%20columns/index.md) + ## Support If you want to request a feature or report a bug regarding macros, use the issues section [on GitHub.](https://github.com/ONLYOFFICE/plugin-macros/issues)