如何制作B列的上升数据并保留借方和信用的相关值?

发布于 2025-01-20 08:50:36 字数 3885 浏览 4 评论 0原文

早上好。

我正在研究Google表。我正在使用应用程序脚本。您可以在以下链接中找到我的文件。

  • [https://docs.google.com/spreadsheets/d/1ce5sppfkftih0udsoddmxb_9cd-hfh5w_q3liois5o8/edit?usp = sharing]

我有一个名为“日记”的表格。

杂志
Année2022fournnisseur
MOI3
日期comptedétbediteopérationsdébitCrédit06forture forture24,006
-MARSGROOVE0624,00
-MARS512BANQUE°
n
12-MARS7巴士民谣音乐会135,00
12-MARS53CAISSE135,00
客户端n°
28-MARS6GROOVE24,00
28-MARS512BANQUE24,00
forture fournisseur n°
totauxà记者183,00183,00

我还有一张名为“ Grand Livre”的表格,我试图以上升的方式报告表“日记帐”的数据(B列)的数据(B列)。 但是,带有“ 7”的帐户的第9行不在最后,应该在最后。

débitCrédit06Mars
-Mars51224
28-Mars51224
12-53135
12-MARS7135
06-MARS624 24
24 28-MARS记者624à
183183183
function monGrandLivre() {
  var journal = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('journal')
  var data = journal.getDataRange().getDisplayValues().filter(r => (!isNaN(Date.parse(r[0]))))
  data = data.sort(function (a, b) {
    return b[1] - a[1];
  });
  var result = []
  result.push(['', '', '', 'Débit', 'Crédit'])
  data.forEach(function (donnees, ligne) {
    result.push([donnees[0], donnees[1], '', donnees[3], donnees[4]])
    if (ligne != (data.length - 1)) {
      if (data[ligne + 1][1] != data[ligne][1]) {
        result.push(['', '', '', '', ''])
        result.push(['', '', '', '', ''])
      }
    }
  })
  var grandLivre = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('grand livre')
  grandLivre.clearContents()
  grandLivre.getRange(1, 1, result.length, result[0].length).setValues(result)
  grandLivre.getRange(result.length + 1, 3).setValue('à reporter')
  grandLivre.getRange(result.length + 1, 4).setFormula('=sum(D2:D' + result.length + ')')
  grandLivre.getRange(result.length + 1, 5).setFormula('=sum(E2:E' + result.length + ')')
}

您能帮我吗?

先感谢您。

Good morning to the community.

I'm working on Google Sheets. I'm using Apps Script. You can find my file in the following link.

  • [https://docs.google.com/spreadsheets/d/1ce5sppfkftIh0uDsODDmXb_9Cd-hfh5w_q3lIoIS5o8/edit?usp=sharing]

I have one sheet named "journal" where I have the data of my journal.

Journal
Année2022
Mois3
DateCompteDétail des opérationsDébitCrédit
06-mars6Groover24,00
06-mars512Banque24,00
facture fournisseur n°
12-mars7Bus balladium concert135,00
12-mars53Caisse135,00
versement client n°
28-mars6Groover24,00
28-mars512Banque24,00
facture fournisseur n°
Totaux à reporter183,00183,00

I have also one sheet named "grand livre" where I tried to report the data of the sheet "journal" and sort the data of the accounts (column B) in an ascendant way.
But, the line 9 with the account "7" is not at the end and should be at the end.

DébitCrédit
06-mars51224
28-mars51224
12-mars53135
12-mars7135
06-mars624
28-mars624
à reporter183183
function monGrandLivre() {
  var journal = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('journal')
  var data = journal.getDataRange().getDisplayValues().filter(r => (!isNaN(Date.parse(r[0]))))
  data = data.sort(function (a, b) {
    return b[1] - a[1];
  });
  var result = []
  result.push(['', '', '', 'Débit', 'Crédit'])
  data.forEach(function (donnees, ligne) {
    result.push([donnees[0], donnees[1], '', donnees[3], donnees[4]])
    if (ligne != (data.length - 1)) {
      if (data[ligne + 1][1] != data[ligne][1]) {
        result.push(['', '', '', '', ''])
        result.push(['', '', '', '', ''])
      }
    }
  })
  var grandLivre = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('grand livre')
  grandLivre.clearContents()
  grandLivre.getRange(1, 1, result.length, result[0].length).setValues(result)
  grandLivre.getRange(result.length + 1, 3).setValue('à reporter')
  grandLivre.getRange(result.length + 1, 4).setFormula('=sum(D2:D' + result.length + ')')
  grandLivre.getRange(result.length + 1, 5).setFormula('=sum(E2:E' + result.length + ')')
}

Can you help me?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小…红帽 2025-01-27 08:50:36

如果您想按文本而不是按值对B进行分类,请按以下方式更改

  data = data.sort(function (a, b) {
    return ('' + a[1]).localeCompare(b[1]);
  })

If you want to sort column B by text and not by value, change as follows

  data = data.sort(function (a, b) {
    return ('' + a[1]).localeCompare(b[1]);
  })
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文