Skip to content

Hotfix preenchimento campo número excel#45

Merged
albertomandlate merged 4 commits intomainfrom
hotfix-preenchimento-campo-numero-excel
Jun 20, 2025
Merged

Hotfix preenchimento campo número excel#45
albertomandlate merged 4 commits intomainfrom
hotfix-preenchimento-campo-numero-excel

Conversation

@albertomandlate
Copy link
Copy Markdown
Contributor

No description provided.

albertomandlate and others added 4 commits June 20, 2025 09:51
Modifica o tipo de célula para várias colunas, assegurando que os dados sejam tratados corretamente como numéricos ou strings. Substitui linhas removidas por novas definições de tipo de célula. Adiciona cálculos para valores relacionados a impostos e totais, melhorando a precisão e clareza dos dados na planilha gerada.
Muito bem observado

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Modificações na forma como os valores são atribuídos às células. A célula 23 agora utiliza `SetCellType(CellType.Numeric)` antes de definir seu valor, assegurando que o tipo seja numérico. A chamada a `SetCellType(CellType.Numeric)` foi removida da célula 28, simplificando a definição do valor.
@albertomandlate albertomandlate requested a review from Copilot June 20, 2025 08:08
@albertomandlate albertomandlate self-assigned this Jun 20, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Hotfix to ensure Excel cells have the correct data types when generating the SAF-T spreadsheet.

  • Explicitly set CellType for key columns (row index, tax number, numeric totals, exchange rate)
  • Converted existing SetCellValue calls to chain with SetCellType for all numeric and string cells
Comments suppressed due to low confidence (2)

src/SAF-T.Mozambique/Generators/MozambiqueSaftGenerator.cs:307

  • Calling SetCellType returns void in NPOI, so chaining SetCellValue will not compile. Use the CreateCell overload that accepts CellType (e.g., row.CreateCell(0, CellType.Numeric).SetCellValue(...)) or split into two statements: capture the cell, call SetCellType, then SetCellValue.
                    row.CreateCell(0).SetCellType(CellType.Numeric).SetCellValue(numeroLinha - 1);

src/SAF-T.Mozambique/Generators/MozambiqueSaftGenerator.cs:308

  • Same as above: SetCellType does not return the cell instance. Switch to row.CreateCell(1, CellType.String).SetCellValue(...) or separate SetCellType and SetCellValue on the cell object.
                    row.CreateCell(1).SetCellType(CellType.String).SetCellValue(auditFile.Header!.TaxRegistrationNumber);

var row = sheet.CreateRow(numeroLinha++);
row.CreateCell(0).SetCellValue(numeroLinha - 1);
row.CreateCell(1).SetCellValue(auditFile.Header!.TaxRegistrationNumber);
row.CreateCell(0).SetCellType(CellType.Numeric).SetCellValue(numeroLinha - 1);
Copy link

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] There's a lot of repeated code for creating cells, setting types, and assigning values. Consider a small helper method (e.g., CreateTypedCell(row, index, type, value)) to reduce duplication and improve readability.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como está, está correcto.

@albertomandlate albertomandlate merged commit f83daf7 into main Jun 20, 2025
5 of 6 checks passed
@albertomandlate albertomandlate deleted the hotfix-preenchimento-campo-numero-excel branch June 20, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants