Kirby Spreadsheet Plugin

@texnixe Im using your spread sheet plugin to generate a list of external resources. However, the content of the spreadsheet contains links to websites. These get stripped out when the table gets generated. How easy would it be to keep the links?

The link in the spreadsheet is text that has had a link added to it inside Excel, rather then a raw URL in the cell. It looks like the reader the plugin depends on can handle this, but it gets lost somewhere, i think the brick in the kirby tag is doing it?

I think this information is probably dropped by the library I use. A quick fix would be some string manipulation that checks if the value starts with http and then wraps that string in a link tag.

But I don’t think i can do that because the information has been lost. I just printed the data straight from the spreadsheet without doing anything at all with it, and theres no URL information in there. Hrmmm…

I think i need to talk directly to php-excel-reader without the other library in between - looking though its code it seems to ignore hyperlink information totally.

What do you mean, even the text information of the URL is lost, so that the column is empty?

Im getting the text data, but not the hyperlink that it should be wrapped in.

That’s why I said, you can wrap it in. a link tag in the loop (tags/spreadsheet.php, line 52ff) if the string start with http:

foreach($row as $key => $cell) {
  if(str::startsWith($cell, 'http://')) {
    $cell = '<a href="' . $cell .'">' . $cell . '</a>';
  $btr->append('<td>' . $cell . '</td>');

A bit of a hack, but should work.

Sure, but what im trying to say is the data isn’t there to work with… if I empty out the kirby tag so its just this, i get an array back but it doesnt contain any URLs at all, just the plain text data from all the cells:

$kirby->set('tag', 'spreadsheet', array(
  'attr' => array(
  'html' => function($tag) {

    $file = $tag->file($tag->attr('spreadsheet'));

    if(! $file) return '';

    $reader = new SpreadsheetReader(kirby()->roots()->content() . DS . $file->diruri());

    foreach ($reader as $Row)

As a work around, i found this neat little command line tool that can convert a spreadsheet into markdown, and retains the URL information.

This is workable for now, but it would be great if the plugin could do it directly.

Is there a kirby tag to include a seperate markdown file into a textarea and have it processed as if it was part of the text inside the textarea? I saw this in the docs, but is that doable in a Kirby tag?

Oh, you mean to say that the links are contained within some text, not just as separate links in a table cell?

No…The spread sheet has two columns. The left one is a link that has been set by pasting a link into the cell from somewhere else (I have a word document with about 300 links and descritptions in it that i need to get into a kirby site).

If you paste a link into excel from a web page or word, it retains the link so you can still click it in excel and it will fire up the web page. You can do it in excel too, by going to insert > link in the toolbar. So the links in the spreadsheet are the name of the website, and its been turned into a clickable link from within excel.

Oh, I see. So you are left with the link text while the link itself is gone and that’s why my suggestion doesn’t work.

Yup. Thats the problem :slight_smile:

Another option would be to save the file as Excel with Macro, create a new function that extracts the URL from the Hyperlink, once that is done, save the file as standard Excel again.

Thanks… the command line tool i linked to above works fine, and gives me a Markdown file. Im just trying to figure out how to add this to the textarea via a kirby tag. So far all ive ended up with is the contents of the markdown file being rendered on my page, it’s not actually turning it into html.