caxlsx / caxlsx_rails

A Rails plugin to provide templates for the axlsx gem
MIT License
744 stars 84 forks source link

Apple Numbers Ignores Hyperlinks from Production, not Development? #67

Closed rylanb closed 6 years ago

rylanb commented 7 years ago

Hello, I'm having a weird error and I doubt its axlsx or axlsx_rails, but I've tried Googling around and just can't find any reference to this issue.

Using Google Chrome, I generate xlsx files and download on Mac OSX.

Links are like this: https://domain-name.us/q/1781/cps/6108 Generated:

cell = sheet.name_to_cell("#{alpha}10")
cell.value = "View"
sheet.add_hyperlink location: quote_carrier_plan_url(@quote.id, cp.id), ref: "#{alpha}10", target: :external 

where 'alpha' is generated by

alpha = ('B'..'Z').to_a[0..@carrier_plans_length]
alpha.each_with_index do |alpha, index|` 

and represents the cell alphabet character I want to reference for looping over several carrier plans.

When i download files generated locally from domain-name.dev:5000 they work fine and link to http://domain-name.dev:5000/q/1781/cps/6108. When on prod they link to https://domain-name.us/q/1781/cps/6108 but the prod ones aren't links in the Numbers opened file.

In Google Drive they work fine.

They format like they are links in Numbers:

screen shot 2017-01-19 at 3 43 38 pm

But don't link! Any thoughts/ideas or pointers?

Thanks!

straydogstudio commented 7 years ago

I'm not expecting it to do anything, but have you tried using shared strings? Sometimes it fixes OSX issues:

render "index", locals: {xlsx_use_shared_strings: true}

After that, I'm wondering if you could run a test in production, running a script with Rails runner, and generating some test spreadsheet with a link in it. Save it on a local drive. In other words, bypass axlsx_rails and the view pipeline. See if the link works. That isn't very likely to help either. But something is changing that spreadsheet.

Is your development server on localhost?

rylanb commented 7 years ago

I run it on domain-name.dev:5000. domain-name.us is where the prod site lives. I'll try putting that local use_shared_strings in and report back on next deploy.

It works fine in Excel/Google Drive, so I think Numbers is doing something funky.

rylanb commented 6 years ago

@straydogstudio sorry to bother, but I'm seeing this occur still, have you heard / seen anything around this?

It is now happening in spreadsheets downloaded in Mac OS (10.11.6) in Chrome / Windows (not sure version) in Chrome AND Internet Explorer. Links are completely not clickable. Any recommendations on how to troubleshoot this? I'm pretty stumped.

format.xlsx {
        template = if params[:orientation] == 'custom-vertical'
                     'show_custom_vertical.xlsx.axlsx'
                   elsif params[:orientation] == 'custom-horizontal'
                     'show_custom_horizontal.xlsx.axlsx'
                   elsif params[:orientation] == 'vertical'
                     'show_vertical.xlsx.axlsx'
                   else
                     'show.xlsx.axlsx'
                   end

        response.headers['Content-Disposition'] = "attachment;filename=#{@filename}#{params[:orientation]}_report.xlsx"
        render template: 'reports/' + template, locals: { xlsx_use_shared_strings: true }
      }
straydogstudio commented 6 years ago

@rylanb I don't have much to offer. Have you tried the latest from the github repo?

There is still the possibility of a newer release of Axlsx (even though it is long overdue, the project is not dead. There is no ETA though.)

I might be able to spend some time next week. No guarantees though, as I have little or no time these days. :-P

straydogstudio commented 6 years ago

@rylanb I mean latest Axlsx.

rylanb commented 6 years ago

So after a LOT of troubleshooting, partially this is an issue with our code (for one sheet the hyperlinks are off 1 cell). So apologies there, I think this clears up what is happening on Windows.

Then what is happening is Microsoft Excel for Mac Version 16.9 seems to have broken link issues.

Thread about it for Word version 16.9: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_mac-mso_365hp/hyperlinks-wont-work-in-word-for-mac-169/6c98d6dc-55f9-4105-bf80-550ad28266b8

Version 16.10 is supposed to fix this bug as best I can tell.

The issue on Mac led us astray and led me to comment again. So I think you don't have to look into anything here! Shakes first at MSFT!

Versions for reference: gem 'axlsx', git: 'https://github.com/randym/axlsx.git', ref: '776037c0fc799bb09da8c9ea47980bd3bf296874'

gem 'axlsx_rails', '0.5.1'

Thanks for responding!

straydogstudio commented 6 years ago

At least it helps to know where the problem is! As far as I know Axlsx merely produces the open standard for xlsx, but obviously there are complications.