Last active
May 31, 2023 19:17
-
-
Save filpgame/f4d18cce6780aca415f5e07b39117bfb to your computer and use it in GitHub Desktop.
Importar dados da NFC-e no site do sefaz pra um arquivo csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var array = document.querySelectorAll("#tabResult > tbody tr") | |
var csv = "" | |
csv = csv.concat("Item;Quantidade;Unidade;Valor unit.;Valor Total", "\n") | |
for (let index = 0; index < array.length; index++) { | |
const el = array[index]; | |
var item = el.querySelector(".txtTit").textContent.trim() | |
var qt = el.querySelector(".Rqtd").innerText.replace("Qtde.:","").replace(",",".").trim() | |
var unit = el.querySelector(".RUN").innerText.replace("UN:","").trim() | |
var unitAmount = el.querySelector(".RvlUnit").innerText.replace("Vl. Unit.:","").replace(",",".").trim() | |
var totalAmount = el.querySelector(".valor").innerText.replace(",",".").trim() | |
csv = csv.concat(item, ",", qt, ",", unit, ",", unitAmount, ",", totalAmount, "\n") | |
} | |
var data = new Blob([csv], {type: 'text/csv'}); | |
var url = window.URL.createObjectURL(data) | |
window.open(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment