Hotfix preenchimento campo número excel#45
Merged
albertomandlate merged 4 commits intomainfrom Jun 20, 2025
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
Pull Request Overview
Hotfix to ensure Excel cells have the correct data types when generating the SAF-T spreadsheet.
- Explicitly set
CellTypefor key columns (row index, tax number, numeric totals, exchange rate) - Converted existing
SetCellValuecalls to chain withSetCellTypefor 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); |
There was a problem hiding this comment.
[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.
Contributor
Author
There was a problem hiding this comment.
Como está, está correcto.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.