-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Voting: import of voters from CSV/Excel #46
Comments
Closed
On a branch of the branch |
If possible, let's use Sheet.js (aka XLSX): https://docs.sheetjs.com/docs/getting-started/installation/nodejs. 🙂 Example export: private downloadDataAsExcel(flatData: any[], title: string): any {
// prepare the Excel's workbook
const wb: WorkBook = { SheetNames: [], Sheets: {}, Props: { Title: title, Author: env.idea.app.title } };
// add the spreadsheet with users data to the workbook
utils.book_append_sheet(wb, utils.json_to_sheet(flatData), '1');
// generate a buffer of the Excel file
return writeFile(wb, title.concat('.xlsx'));
} Example import private parseRecordsFromExcel(excelContent: File): any[] {
try {
const workbook = read(excelContent, { type: 'binary' });
// acquire the header in a preliminar step,
// to avoid a bug that occurs when the last column of the first not-header row is empty
const header = utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]], { raw: true, header: 1 })[0];
// acquire the rows, forcing the header read in the first row
const rows = utils.sheet_to_json(workbook.Sheets[workbook.SheetNames[0]], {
raw: true,
header: header as any,
defval: '',
range: 1 // skip header row
});
return rows;
} catch (err) {
return [];
}
} |
uatisdeproblem
added a commit
that referenced
this issue
Dec 28, 2023
uatisdeproblem
added a commit
that referenced
this issue
Dec 28, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The placeholder button is already in place. More or less, this is the expected result:
Everything must happen front-end.
If possible, let's also add the export of the same list.
Note: the maximum amount of voters is 1000.
The import substitute the previous values (i.e., remove all → import).
The text was updated successfully, but these errors were encountered: