Code Monkey home page Code Monkey logo

excellentexport's People

Contributors

aureliojargas avatar bjarneheden avatar brockfanning avatar daedalusdev avatar dependabot-preview[bot] avatar dependabot[bot] avatar erunamojazz avatar jacktherock avatar jehon avatar jmaister avatar plachance avatar renovate-bot avatar unabashed avatar wucao avatar yooneskh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

excellentexport's Issues

Uncaught ReferenceError: ExcellentExport is not defined

The compressed file:

    "function" === typeof define && define.c ? define(function() {
            return l
        }) : "undefined" !== typeof exports ? ("undefined" !== typeof module && module.b && (exports = module.b = l), exports.a = l) : r.a = l

This is the only way to use:

<a download="2017-1-12.xls" href="javascript:;" class="btn" title="Download Excel" onclick="return a.excel(this, 'stockup', 'Sheet1');">Download</a>

Cells formatting

Hi,

Do you plan to implement cells formatting? Like background color for example?
Thanks

Doesn't work on IE

Tried the script in IE. Doesn't work. I suspect its because IE doesn't support data protocol. Have you tested your script on an IE browser (cause I see you have mentioned that its IE compatible) ?

Allow assigning a start row.

Using this with Tablesorter and using the Tablesorter Filter option it creates a row that looks like an Excel Filter but doesn't work like one. Need to leave out the Tablesorter Filter to export but if you could tell it to start on the 2nd row then it would work just fine.

Maybe need to set border.

This project is simple enough and useable! Great!
But I think many usage is to export html table to excel report, so I think there is border in excel will be better for custom.

So if this project can config border or just set table style for border, it may be great.

Exporting CSV & Excel with IE

var ee = {
    /** @expose */
    excel: function(anchor, table, name, filename) {
        if (!filename) var filename = 'output.xls'; 
        table = get(table);
        var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML};
        var isIE = /*@cc_on!@*/false || !!document.documentMode;
        if((navigator.appVersion.indexOf("MSIE") >= 0) || (isIE == true)) {
            myFrameTableDownloadIE.document.open("text/html", "replace");
            myFrameTableDownloadIE.document.write(format(template.excel, ctx));
            myFrameTableDownloadIE.document.close();
            myFrameTableDownloadIE.focus();
            myFrameTableDownloadIE.document.execCommand('SaveAs', true, filename);            
        } else {
            var hrefvalue = uri.excel + base64(format(template.excel, ctx));
            anchor.href = hrefvalue;
        }
        // Return true to allow the link to work
        return true;
    },
    /** @expose */
    csv: function(anchor, table, delimiter, newLine, filename) {
        if (!filename) var filename = 'output.csv';
        if (delimiter !== undefined && delimiter) {
            csvDelimiter = delimiter;
        }
        if (newLine !== undefined && newLine) {
            csvNewLine = newLine;
        }
        table = get(table);
        var csvData = tableToCSV(table);

        var isIE = /*@cc_on!@*/false || !!document.documentMode;
        if((navigator.appVersion.indexOf("MSIE") >= 0) || (isIE == true)) {
            myFrameTableDownloadIE.document.open("text/html", "replace");
            myFrameTableDownloadIE.document.write(csvData);
            myFrameTableDownloadIE.document.close();
            myFrameTableDownloadIE.focus();
            myFrameTableDownloadIE.document.execCommand('SaveAs', true, filename);            
        } else {
            var hrefvalue = uri.csv + base64(csvData);
            anchor.href = hrefvalue;
        }
        return true;
    }

Replace line breaks in cell text with single space

Cells containing newline characters will have text smashed together. This can be fixed with something like the code below. Note the use of col.innerText, which preserves newlines which can then be replaced in fixCSVField.

    var fixCSVField = function(value) {
        var fixedValue = value;
        var addQuotes = (value.indexOf(csvDelimiter) !== -1) || (value.indexOf('\r') !== -1) || (value.indexOf('\n') !== -1);
        var replaceDoubleQuotes = (value.indexOf('"') !== -1);
        var replaceLineBreaksWithSpace = ((value.indexOf('\r') !== -1) || (value.indexOf('\n') !== -1));

        if (replaceLineBreaksWithSpace) {
             fixedValue = fixedValue.replace(/(\r\n|\n|\r)/gm," ");
        }
        if (replaceDoubleQuotes) {
            fixedValue = fixedValue.replace(/"/g, '""');
        }
        if (addQuotes || replaceDoubleQuotes) {
            fixedValue = '"' + fixedValue + '"';
        }
        return fixedValue;
    };

    var tableToCSV = function(table) {
        var data = "";
        var i, j, row, col;
        for (i = 0; i < table.rows.length; i++) {
            row = table.rows[i];
            for (j = 0; j < row.cells.length; j++) {
                col = row.cells[j];
                data = data + (j ? csvDelimiter : '') + fixCSVField(col.innerText.trim());
            }
            data = data + csvNewLine;
        }
        return data;
    };

Chrome crashed

If I am going to export large amount of data like 4000 rows then it will crashed.

What should i do to solve this issue?

Returned Excel Sheets have sheet name 'undefined'

Using the minified version of the master branch, when I call ExcellentExport.excel(this, 'exportMe', 'Sheet1'); or ExcellentExport.excel(this, 'exportMe'); the resulting Excel file has it's sheet named 'undefined'.

The un-minified script works as expected.

All other aspects of this script work great. Thanks for your work on this!

For what it's worth, this is in Chrome 35.0.1916.114 m

MS Excel don't understand separator

Hey @jmaister ,
we are using your cool solution but we encounter an issue, our MS Excel don't understand the ',' seperator so we want to change it to another one 'tab or ";"' can we do this easily with your solution? I didn't find anything in this direction in the readme.

Data display in mess when export large data to excel

I export a table with rowspan to excel, it works well when data were not large , but if i export large data from table to excel, the data display in mess .And I found the issue usually happened from 3856th row ,no matter which record in that row.
image

Ouch...doesn't work in Firefox

Getting this error.

15:30:54.009 TypeError: Argument 2 of URL.createObjectURL can't be converted to a dictionary. 1 excellentexport.min.js:8:419

I don't get this error in chrome or IE, for the same page.

Adding font names for better rendering in Indic fonts

As I am using Indic (Malayalam) fonts, the exported excel sheet is not rendered properly. Is it possible add some fonts like 'rachana' or 'dyuthi' which should be automatically rendered in the excel spreadsheet.

missing file: bootstrap.min.css

With version 2.2 I'm getting this error when trying to open the file (MacOS), was working on previous versions.
screen shot 2017-01-12 at 09 51 08
Yes I use Bootstrap on my page, yes the table have some images (but it was working before)

Firefox Error (TypeError: Argument 2 of URL.createObjectURL can't be converted to a dictionary)

Hello, we were testing in Firefox developer edition (Linux 64bits 52.0a2 now, but its same in FF stable) the index.html, but that does not work. That was the error:

TypeError: Argument 2 of URL.createObjectURL can't be converted to a dictionary.[Learn More]  excellentexport.js:105:27

The "Learn More" is a link to https://developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/No_properties?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default

The problem is that window.URL.createObjectURL() only receive one argument (the blob): https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL

Gridlines not shown

Even if <x:DisplayGridlines/> is present in xls template, gridlines are not shown when opened in Excel (Excel 2011 Mac OS).

I had to add <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 11"> to template, just before <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> to make them appear.

export xls with a image

Hi does this library allow me to export a xls with a image somewhere on a sheet?
if there are any examples on the web showing this it would also be great..
thanks
James

Acentuação

Estou tendo problemas com acentuação. Alguma dica para resolver?!
enconding da página está em UTF-8.

xlsx support

I want to export my html table to xlsx instead of xls. Any support for this?

Large table crashes Chrome

I have a 73 column, 219 row table (yeah don't ask), trying to export it crashes Chrome, FYI.
(well it crashes the Chrome tab)

How to import in es6?

I'm using Node and Webpack and Babel to build/transpile.

import * as ExcellentExport from 'excellentexport/excellentexport'
import ExcellentExport from 'excellentexport/excellentexport'
import excellentexport from ExcellentExport from 'excellentexport'

None of these seem to work. Do you have an es6 example of importing a node-installed version?

customize the style of <td>

Hi, cool repo!
In my table, some <td> may contain href (might be javacript:void(0)) , some may be set to display:none, and I don't want them in the final .xls file. So I'm wondering if there's any way to do it, by an option for example ?

'Frame load interrupted' in safari

When trying to export both a CSV and Excel sheet, I get a 'Frame load interrupted' error in the console, and the file isn't downloaded.

Make exceptions for certain columns?

So I have a column that I don't want to appear in the exported Excel file (this column contains buttons/links that only work on the web) -- Maybe mark cells to exclude with a certain CSS class or something. Like
<td data-excel-export-exclude="true">my buttons are here</td>
or something of the sort.

Add IE support

As part of pull request #44 to resolve issue #12 I was able to extend the new non-blob URL generation to support IE downloads.

JS is exported if cell contains <script>

I have some cells that need to execute some JS, so the cell contains <script>var someJS = 'some value';</script>. When I export, "var someJS = 'some value';" is included in the Excel cell, which is not ideal. I've worked around this by adding additional checks in the regex to find <script></script> tags and add html comments around them so that Excel doesn't display them, but I'd like that built in so I don't have to use a custom version of the script.

Additional hacky code added around line 104 in the ExcellentExport function definition

// comment out scripts so the JS doesn't appear in Excel
c.table = c.table.replace(new RegExp("<script", "g"), function(m,p) {
    return "<!-- <scr"+"ipt";
});
c.table = c.table.replace(new RegExp("</script>", "g"), function(m,p) {
    return "</scr"+"ipt> -->";
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.