Skip to content

Commit

Permalink
UPDATE index.md, changelog FIX grmticl errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eeshaansawant committed Dec 23, 2024
1 parent d3cd2a8 commit ba0411b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Change Log

- docs api: the editorConfig.customization.mobileForceView parameter is deprecated, please use the editorConfig.customization.mobile parameter instead
- macros: added import hyperlinks in spreadsheet macro sample

## 6.2.0
- docspace js sdk: storybook link
Expand All @@ -24,7 +25,6 @@
- 404 page
- legacy version link
- macros: added add comments and change cell colors in spreadsheet macro sample
- macros: added import hyperlinks in spreadsheet macro sample

## 6.1.0
- docspace js sdk: react component
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
---
order:
order:
---

## Description

Import hyperlinks between different worksheets in the spreadsheet.
Imports hyperlinks between different worksheets in the spreadsheet.

<!-- This code snippet is shown in the screenshot. -->

<!-- eslint-skip -->

```ts
var oWorksheetA = Api.GetSheet("Sheet1");
var oWorksheetB = Api.GetSheet("Sheet2");
var rowIndex = 0;
var titles = [];
var links = [];
while (rowIndex < 10) {
(function () {
var oWorksheetA = Api.GetSheet("Sheet1");
var oWorksheetB = Api.GetSheet("Sheet2");
var rowIndex = 0;
var titles = [];
var links = [];
while (rowIndex < 10) {
var titleCell = oWorksheetA.GetRangeByNumber(rowIndex, 0); // Assuming title is in column A
var linkCell = oWorksheetA.GetRangeByNumber(rowIndex, 1); // Assuming link is in column B
var title = titleCell.GetValue();
var link = linkCell.GetValue();
titles.push(title); // Store titles in an array
links.push(link); // Store links in an array
links.push(link); // Store links in an array
rowIndex++; // Increment the row index for the next iteration
}
var rangeB = Api.GetSelection();
rangeB.ForEach(function (cell) {
}
var rangeB = Api.GetSelection();
rangeB.ForEach(function (cell) {
var cellValue = cell.GetValue();
// Check if the cell value matches any of the titles from the array
var index = titles.indexOf(cellValue);
if (index !== -1) {
var title = titles[index];
var link = links[index];
var address = cell.GetAddress(true, true, "xlA1", false);
// Set the hyperlink in oWorksheetB
oWorksheetB.SetHyperlink(address, link, "Your Description", title);
var title = titles[index];
var link = links[index];
var address = cell.GetAddress(true, true, "xlA1", false);
// Set the hyperlink in oWorksheetB
oWorksheetB.SetHyperlink(address, link, "Your Description", title);
}
})
});
})();
```

Methods used: GetSheet, GetRangeByNumber, GetValue, GetSelection, ForEach, GetAddress, SetHyperlink
Expand All @@ -47,6 +49,37 @@ Methods used: GetSheet, GetRangeByNumber, GetValue, GetSelection, ForEach, GetAd
<!-- code generated with AI -->

```vb
Sub AddHyperlinks()
Dim wsA As Worksheet, wsB As Worksheet
Dim titles() As String, links() As String
Dim rng As Range, cell As Range
Dim i As Integer

' Set worksheets
Set wsA = ThisWorkbook.Sheets("Sheet1")
Set wsB = ThisWorkbook.Sheets("Sheet2")

' Read first 10 titles and links from Sheet1
ReDim titles(0 To 9)
ReDim links(0 To 9)
For i = 0 To 9
titles(i) = wsA.Cells(i + 1, 1).Value ' Column A
links(i) = wsA.Cells(i + 1, 2).Value ' Column B
Next i

' Loop through the selection on Sheet1
Set rng = Selection
For Each cell In rng
For i = LBound(titles) To UBound(titles)
If cell.Value = titles(i) Then
' Add hyperlink to Sheet2 at same address as the selected cell
wsB.Hyperlinks.Add Anchor:=wsB.Cells(cell.Row, cell.Column), _
Address:=links(i), _
TextToDisplay:=titles(i)
End If
Next i
Next cell
End Sub
```

## Result
Expand Down
4 changes: 3 additions & 1 deletion site/pages/Docs/Plugin and Macros/Macros/Samples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ In this example we are adding comments and changing the background colors of sel

[More](Add%20comments%20and%20change%20cell%20colors%20in%20spreadsheet/index.md)

## Import hyperlinks in spreadsheet
## Import hyperlinks

[More](Import%20hyperlinks/index.md)

In this example we are importing hyperlinks between different worksheets in the spreadsheet.

Expand Down

0 comments on commit ba0411b

Please sign in to comment.