Created attachment 181540 [details] Simple test case If you create a rather long link (I happen to be creating multiple destination routes in Google Maps and add them to a cell (via CTRL+K), they work as expected until you save and re-open the file as XLSX. It works properly if you use ODS. For example, if a link is 300 characters, it gets truncated to 'about' 256 characters. I get variable lengths, but always in the 256 ballpark, so there's probably something to do with the specific string contents. I've attached a two cell sheet. Just copy the link contained in A1 using CTRL+K after selecting A2. Close, re-open, voila. 1) open LINKS.XLSX 2) select cell A1, hit CTRL+C 3) select cell A2, highlight "LINKS" 4) hit CTRL+K, hit CTRL+V, close 5) CTRL+leftclick to go to link in browser 6) Save/Close/reopen and try #5 again.
Code pointer: https://opengrok.libreoffice.org/xref/core/sc/source/filter/excel/xecontent.cxx?r=9f1701d0#407
All those XclExpString instances that truncate to 255 probably need to distinguish between BIFF and OOXML export and truncate only for BIFF. Just guessing, untested. (if OOXML actually allows longer strings in that context).
There is a work-around: In the provided example a2 = hyperlink(a1;"text") allows an offsheet or hidden cell to contain the link in plain text, which doesn't get truncated.
(In reply to Eike Rathke from comment #2) I can't tell if this is applicable (or if my test shows Excel storing those strings in a different internal structure, and thus comparing apples to oranges?), but MS Excel 2016 allows storing that long URLs also in XLS. So at least in this case, a *possible* fix could be to just increase the limit for all uses.
(In reply to Mike Kaganski from comment #4) On the other hand: I tried to *create* such a link in Excel manually. I created an artificial URL of 2 700 000 characters (hoping that it would either show "there's no practical limit", or cut it down to an acceptable limit), and pasted into Excel's Ctrl+K hyperlink dialog. The result was "The address for this hyperlink exceeds the 255-character limit. Please reduce the number of characters." The message is indeed misleading, likely showing that Excel had such a limit at some point (95?), and didn't update error messages since increasing it. And the actual limit seems to be strange 2083 characters in the URL (it starts to show that dialog at 2084 characters). Note that the testing was done with the default-created new Excel document, not with an XLS (legacy format), where some additional limitations could apply, nor with any "compatibility mode".
... and for XLS 97-2003, the actual limit (after which silent loss of hyperlink happens at save) is weird 1987 characters (1988 is lost).
And finally: for XLS 5.0-95, I couldn't persuade Excel 2016 to save even a short URL like https://example.org/.
(In reply to Mike Kaganski from comment #5) > And the actual limit seems to be strange 2083 characters in the URL (it > starts to show that dialog at 2084 characters). > > Note that the testing was done with the default-created new Excel document, > not with an XLS (legacy format), where some additional limitations could > apply, nor with any "compatibility mode". It looks strange now to me, after accidentally revisiting this due to https://ask.libreoffice.org/t/hyperlink-truncation-problem/125638 ; and testing now, I see the limit of 8192 characters in the URL for XLSX.
Created attachment 202450 [details] XLSX with 8192-character hyperlink
Created attachment 202451 [details] XLS with 2083-character hyperlink
On my MS Excel 2016 (16.0.5513.1000) configuration: 1. File hyperlink2083ch.xls. The file opens normally. The hyperlink opens normally. When trying to change the hyperlink, a message (localized) appears: "The hyperlink address is longer than 255 characters. Reduce the number of characters." 2. File hyperlink8192ch.xlsx When opening, a message is displayed about the file structure being damaged. After restoration, the hyperlink length is 2084 characters. The situation with editing the hyperlink is the same as with the previous file.
Maybe (if it's not too much work) add a Parameter containing the maximum length of a hyperlink when exporting to MS Excel format (0 - do not shorten hyperlinks)?
https://gerrit.libreoffice.org/c/core/+/190078
Mike Kaganski committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/core/commit/f41c58ad4172729a2be261f0ccea01d741d61a2d tdf#150229: increase maximum size of URLs for Excel file formats export It will be available in 26.2.0. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
(In reply to Vladimir Sokolinskiy from comment #12) > add a Parameter containing the maximum length of a hyperlink when exporting to > MS Excel format No. We must not add parameters for infinite flexibility; we must not add parameters "let user play with external file format, because we are unsure", etc. The fix hardcodes the known constants of limits. If a better knowledge appears, we will adjust them.
Mike Kaganski committed a patch related to this issue. It has been pushed to "libreoffice-25-8": https://git.libreoffice.org/core/commit/8013104ecc2e1a297cb238024c9a6100b07ff84d tdf#150229: increase maximum size of URLs for Excel file formats export It will be available in 25.8.1. The patch should be included in the daily builds available at https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: https://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.