-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull Request welcome? InsertRows, SearchCellsByValue, ReplaceCellValue #71
Comments
Hi,
Over all, the functions sounds interesting. If you want, you can create a PR with the target branch DevPR. I would review the PR as soon as possible.
I'm looking forward to your answer and your possible PR. |
Thank you for your response! Here my answers to your Questions: InsertRow: What are you inserting there? Just the row definitions, or are you defining empty cells, based on the existing columns?Exactly, I insert new, empty cells and adopt the format from the first row. FirstOrDefaultCell: I assume it returns null (is Default?), if the value type is not supported or no value like that found, right?That's correct. It returns null or the Cell. FirstOrDefaultCell(object searchValue) and FirstOrDefaultCell(Func<Cell, bool> predicate): Have you considered a search direction, like the enum
|
Date | Amount | Balance |
---|---|---|
Payments | \$Payments\$ | |
Taxes | \$Taxes\$ | |
Other Stuff |
For Payments, there is only one row. However, there could be multiple rows, so I need the InsertRow
method.
The same applies to Taxes.
The result could look something like this:
Date | Amount | Balance |
---|---|---|
Payments | 31.12.2024 | 5.25 |
15.01.2025 | 10.00 | |
18.01.2024 | -2.23 | |
Taxes | 31.12.2024 | 5.00 |
30.03.2024 | 5.00 | |
Other Stuff |
I add 2 rows (for Payments) and 1 row (for Taxes) and populate the new cells with the values.
I take a somewhat "brutal" approach: I remove all cells below \$Payments\$
, add new cells, and populate them with values. Then, I re-add the previously removed cells (but with a new address and new key).
For large Excel files, this might be somewhat inefficient. The problem is that the key in a Dictionary cannot be modified.
Then, I’ll take the plunge and make a pull request – it will be my first! :)
I’ve added tests, but I often lack creativity in this area.
Thanks for the detailed explanation and the PR. I will look at it as soon as possible in January. An additional note about the purpose of NanoXLSX/PicoXLSX/NanoXLSX4j: Furthermore, I wish you a happy new year |
A new version 2.6.0 of NanoXLSX (and PicoXLSX 3.4.0) was released some minutes ago and is already online as NuGet package. Besten Dank für die Features 👍 |
Thanks for the information! The new package works wonderfully and does what it should. Thanks for letting me learn so much about GitHub and unit testing! Viele Grüße aus Bayern in die Schweiz. 👋 |
In my small project, I use nanoXLSX to create a simple Excel file.
I open an existing file (template) and replace placeholders with the desired values.
For multiple records, I add new rows to the Excel sheet.
To achieve this, I have extended nanoXLSX with the methods listed below.
I am unsure if these methods would be of interest for nanoXLSX.
Should I make them available to you and create a pull request?
(This would be my very first pull request ever!)
These are the methods:
public void InsertRow(int rowNumber, int numberOfNewRows)
Adds a specified number of new rows below the given row.
The format of the upper row is applied to the new rows.
Note: Formulas are not adjusted!
public Cell FirstCellByValue(object searchValue)
Searches for the first cell containing the specified value and returns the cell.
public Cell FirstOrDefaultCell(Func<Cell, bool> predicate)
Searches for the first cell that matches the given predicate and returns the cell.
public int ReplaceCellValue(object oldValue, object newValue)
Finds all cells with the value "oldValue" and replaces it with "newValue."
I have already created a fork and a new branch in it. However, I have not yet pushed the commit...
The text was updated successfully, but these errors were encountered: