{"id":16672762,"url":"https://github.com/kktsvetkov/heiho","last_synced_at":"2025-03-21T17:32:58.870Z","repository":{"id":57125006,"uuid":"296232032","full_name":"kktsvetkov/heiho","owner":"kktsvetkov","description":"Quick spreadsheet viewer in vanilla JS","archived":false,"fork":false,"pushed_at":"2020-10-29T09:24:53.000Z","size":64,"stargazers_count":21,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T12:07:32.534Z","etag":null,"topics":["csv","javascript","spreadsheet","spreadsheet-viewer","spreadsheets","vanilla-js"],"latest_commit_sha":null,"homepage":"https://kktsvetkov.github.io/heiho/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kktsvetkov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-17T05:51:55.000Z","updated_at":"2024-08-22T19:47:45.000Z","dependencies_parsed_at":"2022-08-31T08:20:15.846Z","dependency_job_id":null,"html_url":"https://github.com/kktsvetkov/heiho","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kktsvetkov%2Fheiho","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kktsvetkov%2Fheiho/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kktsvetkov%2Fheiho/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kktsvetkov%2Fheiho/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kktsvetkov","download_url":"https://codeload.github.com/kktsvetkov/heiho/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221817419,"owners_count":16885531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","javascript","spreadsheet","spreadsheet-viewer","spreadsheets","vanilla-js"],"created_at":"2024-10-12T12:07:13.344Z","updated_at":"2024-10-28T10:32:55.175Z","avatar_url":"https://github.com/kktsvetkov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Heihō\n\nQuick spreadsheet viewer in vanilla JS\n\n![Heihō](https://user-images.githubusercontent.com/694812/93581130-62c3a680-f9a9-11ea-8302-f47f94d4bdf5.png)\n\n# What it does ?\n\nThe `heiho.js` script is quick and simple spreadsheet viewer. It is meant to\npreview the contents of **csv** files inside your browser without needing\nany other tools. It uses plain vanilla javascript so it has no dependencies,\nbut for the applied styling from the css file.\n\nThis is not a spreadsheet editor, this is a preview tool only.\n\n# How to use ?\n\nSimply include both the [javascript file](https://github.com/kktsvetkov/heiho/blob/master/heiho.js) and the [css stylesheet](https://github.com/kktsvetkov/heiho/blob/master/heiho.css) in your HTML document.\nIt's best if you put them at the bottom, close to the closing `\u003c\\body\u003e` tag.\n\n```html\n\u003clink rel=\"stylesheet\" href=\"/path/to/heiho.css\" /\u003e\n\u003cscript src=\"/path/to/heiho.js\"\u003e\u003c/script\u003e\n```\n\nOr include it via [jsDelivr CDN](https://www.jsdelivr.com/features#gh):\n\n```html\n\u003clink rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/gh/kktsvetkov/heiho@latest/heiho.css\" /\u003e\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/kktsvetkov/heiho@latest/heiho.js\"\u003e\u003c/script\u003e\n```\n\nOnce included in your document, simply call `Heiho()` and pass the data as argument\n\n```js\nvar data = [ ['a', 'b', 'c'], [1,2,3], [4,5,6] ];\nHeiho(data);\n```\nYou can modify some of the output using a second argument that passes additional\noptions\n```js\nHeiho(data, {max:20}); // shows only 20 rows from data\n```\n\nExplore more cases in the examples section below.\n\n# Options\n\nThere is a small set of options used to influence the output of the spreadsheet\npreview.\n\n* `options.header` is boolean value whether to style the first row in the  \npreview differently; this meant to be used with CSV files, where the first\nrow holds the column titles; default value is `null` which triggers an attempt\nto auto-detect whether the first row is header or not.\n\n* `options.max` is an integer value that restricts how many rows to be included\nin the preview; you can use `0` to disable it, and its' default value is 100.\n\n* `options.title` this is used to output the header title; you can use a string\nto just pass a text to be inserted there, or you can use a function that manipulates\nthe HTML element that is the header title (look in the examples below)\n\n* `options.truncate` is a function used to render the output in the \"truncate\"\nelement of the preview; this element appears if the rows of the data previewed\nare more than `options.max` as an acknowledgement that the data was truncated\n(look in the examples below to see how this work)\n\nOptions are passed as a second argument to `Heiho()` function.\n\n```js\nHeiho(data, { max: 20, title: 'proba.csv' });\n```\n\nYou can add more elements to the options argument which you can later use in\nsome of the functions inside it such as `options.title` and `options.truncate`.\n\n# Examples\n\nLet's explore few examples of what you can do with **Heihō**\n\n## Title\n\nYou can modify what is rendered in the header title of the preview. The basic\napproach here is to just pass the title as a string in the options, like this:\n\n```js\nHeiho(data, { title: 'users.csv' });\n```\n\nYou can also do more with it if you pass a function as the title. In that case\nit will be executed to populate the contents of the header title will be. The\narguments are the header title element, and the options used.\n\n```js\nvar file = {filename: 'Proba.csv', size: '123KB', created: '2009-08-21 14:01:36'}\nHeiho(data, { title: function(el, o)\n\t{\n\t\tel.innerHTML = '\u003cb\u003e'\n\t\t\t+ file.filename + '\u003c\\/b\u003e \u003ccode\u003e'\n\t\t\t+ file.size + '\u003c\\/code\u003e '\n\t\t\t+ file.created;\n\t}\n});\n```\n\n## Truncate\n\nSimilar to how `options.title` is used as a function, `options.truncate` is\nused to populate the contents of the \"truncate\" element (the warning shown when\nthere are more rows to preview than the `options.max` restriction). This\nfunction gets more arguments:\n\n```js\n/**\n* @param {DomElement} el the truncate element\n* @param {Integer} max\n* @param {Array|Object} data data previewed\n* @param {Object} o options\n*/\noptions.truncate = function(el, max, data, o)\n{\n\tel.innerHTML = 'Showing only first ' + max + ' rows';\n\tel.style.display = '';\n}\n```\n\n## Papa Parse\n\nYou can use the popular [Papa Parse](https://www.papaparse.com/) ([github](https://github.com/mholt/PapaParse)) library\nto parse CSV data inside your browser. You can use it together with **Heihō** to\npreview the result from the CSV parsing\n\n```js\nPapa.parse(file, {\n\tcomplete: function(results) {\n\t\tHeiho(results.data);\n\t}\n});\n```\n\nExplore all the examples on [papaparse.com](https://www.papaparse.com/), they are a blast!\n\nHere's an example of Papa Parse and Heiho previewing a remote csv file:\n```js\nPapa.parse(\"http://example.com/file.csv\", {\n\tdownload: true,\n\tcomplete: function(results) {\n\t\tHeiho(results.data);\n\t}\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkktsvetkov%2Fheiho","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkktsvetkov%2Fheiho","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkktsvetkov%2Fheiho/lists"}