Skip to content

Instantly share code, notes, and snippets.

@filpgame
Last active May 31, 2023 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save filpgame/f4d18cce6780aca415f5e07b39117bfb to your computer and use it in GitHub Desktop.
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
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