Hi,
I want to put text into one cell, while I know Cell reference is like B2. How to adjust this
that is from this URL, to update specific cell to given value?
I want to put text into one cell, while I know Cell reference is like B2. How to adjust this
public static void InsertText(string docName, string text) { // Open the document for editing. using (SpreadsheetDocument spreadSheet = SpreadsheetDocument.Open(docName, true)) { // Get the SharedStringTablePart. If it does not exist, create a new one. SharedStringTablePart shareStringPart; if (spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().Count() > 0) { shareStringPart = spreadSheet.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First(); } else { shareStringPart = spreadSheet.WorkbookPart.AddNewPart<SharedStringTablePart>(); } // Insert the text into the SharedStringTablePart. int index = InsertSharedStringItem(text, shareStringPart); // Insert a new worksheet. WorksheetPart worksheetPart = InsertWorksheet(spreadSheet.WorkbookPart); // Insert cell A1 into the new worksheet. Cell cell = InsertCellInWorksheet("A", 1, worksheetPart); // Set the value of cell A1. cell.CellValue = new CellValue(index.ToString()); cell.DataType = new EnumValue<CellValues>(CellValues.SharedString); // Save the new worksheet. worksheetPart.Worksheet.Save(); } }
that is from this URL, to update specific cell to given value?
Many Thanks & Best Regards, Hua Min