SheetConverter icon indicating copy to clipboard operation
SheetConverter copied to clipboard

Links @ the html table

Open alxkutovoy opened this issue 9 years ago • 7 comments

Hi David!

Hope you're doing well! Firstly, I'd like to say THANK YOU for your outstanding work and the SheetConverter in particular. You saved A LOT of time for me and numerous users. I really appreciate your effort and contribution!

May I kindly ask whether it might be possible in the nearest future to export tables that might contain links in some cells?

Thank you and have a wonderful day!

Alex

[email protected]

screen shot 2016-06-27 at 14 59 55 screen shot 2016-06-27 at 15 00 04

alxkutovoy avatar Jun 27 '16 12:06 alxkutovoy

This was not an option before but as of the June 2020 update, there is now a method to do this but might make for a lot of extra complications, it would depend on do we want to support only one hyper link per cell or multiple hyper links per cell (which is now possible)? I would vote only one per cell as multiple ones just seems like a lot on complications with little end results.

ChadEmory avatar Jul 22 '20 21:07 ChadEmory

OK, I worked out code to get the URL links of the data Range, code below, but I can't seem to work out where to inject the html code for the cells in the script. Any one have an idea?

Here is my code to gather the HTMLlinks for the range just place this code starting at line 225, the code will make an array with html that matches HTML in the data range and 0 (zero) where there is no URL.

******* Code starts here ********* // Get the UrlLinks for range var urlLinks = []; for (var row=startRow; row<lastRow; row++) { var w = []; for (var col=startCol; col<lastCol; col++) { var url = null; var url = sheet.getRange(row,col).getRichTextValue(); var urlString = null; if (url){ urlString = sheet.getRange(row,col).getRichTextValue().getLinkUrl(); } if ((url == null)|(urlString ==null)) { urlString = 0;} w.push(urlString); } urlLinks.push(w); } ***** Code ends here *******

ChadEmory avatar Jul 27 '20 17:07 ChadEmory

@ChadEmory i made a little changes to let the link included in html, add codes after line 294: https://github.com/mogsdad/SheetConverter/blob/1f11b8ddcc4cbb36d88d429e427e861b1e7eb960/SheetConverter/Code.gs#L294

        var richValue = range.getCell(row+1,col+1).getRichTextValue();
        var linkUrl = richValue && richValue.getLinkUrl();
        if(linkUrl) {
          cellText = `<a href="${linkUrl}" target="_blank">${cellText}</a>`;
        }

it was using in my local and not tested on a large scale, just provide an idea.

rugbbyli avatar Jul 28 '20 14:07 rugbbyli

@rugbbyli - When I try your code I get an illegal character on the next to the last line of your code -

cellText = <a href="${linkUrl}" target="_blank">${cellText}</a>;

ChadEmory avatar Jul 28 '20 16:07 ChadEmory

Worked out all the details to get this working an tested, put in a pull request to have added to the master code. #19

ChadEmory avatar Jul 30 '20 14:07 ChadEmory

@ChadEmory Hi there, just checking if your request has been implemented in the master code of the main library yet, or are you using your own? Thanks!

kikko616 avatar Oct 27 '20 14:10 kikko616

It as not been incorporated into the code here. I do have it in my code branch on github. Just export it and paste into your own script in Google and enjoy.

ChadEmory avatar Oct 29 '20 15:10 ChadEmory