C# Assigning numericUpDown value to a specific cell in Excel file

43 Views Asked by At

Heres what I have:

if (int.TryParse(kit_csv_quantity.Text, out int kitOut))
            {
                decimal kitOutValue = kitOut + kits_upDown.Value;
                kit_csv_quantity.Text = kitOutValue.ToString();
                ItemLine IL = new ItemLine();
                kitOutValue = IL.Quantity;
                allItems.Add(IL);
                
                SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
                var workbook = ExcelFile.Load(@"C:\\Users\\carson.sumner\\Desktop\\PSP Kanban Program\\Backend Files\\Kits_be.csv", new CsvLoadOptions(CsvType.CommaDelimited));
                var worksheet = workbook.Worksheets[0];
                var row = worksheet.Rows[worksheet.Rows.Count];
                var column = worksheet.Columns[worksheet.Columns.Count];

                var searchText = kit_csv_quantity.Text;
                var range = worksheet.Cells.GetSubrange("C2:C25");

                row.Cells[2].Value = searchText;

                workbook.Save("Output.csv", new CsvSaveOptions(CsvType.CommaDelimited));

What I have works to get the numericUpDownValue and add it into the Spreadsheet, but it just adds it into the bottom of the spreadsheet. What I want to be able to do is use the numericUpDownValue to edit a value in a pre-existing cell in the spreadsheet.

I am using gembox-spreadsheet to read the csv file into an excel workbook to edit the values, and then writes the excel worksheet back into a csv file.

0

There are 0 best solutions below