After 2 days of trying to learn Open XML, I have the following small piece of code so far:
Dim SD As SpreadsheetDocument = SpreadsheetDocument.Open(DocName, True) Dim sheets As Sheets = SD.WorkbookPart.Workbook.Sheets Dim SESheet As Sheet For Each sh As Sheet In sheets if sh.Name = "Score Entry" then SESheet = sh end if Next
Dim C As New Cell() C.CellReference = "B3" Dim CV As New CellValue() CV.Text = "123456" C.CellValue = CV SD.Close()
This code runs without any errors, but when I look at the spreadsheet, the cell has not been changed. I'm sure I've done something wrong or forgotten something. Could someone people me in the right direction?
Thanks,Jesse
Hi,
Can you please elaborate what you are trying to do. Are you looking to update the existing cell with a new value or you want to create a new cell altogether?
I kept plugging away at this for a very long time and after 3 days finally got it working. I was trying to hand-code everything to match the application this will be going into. I finally gave that up and created a Visual Studios app, and when I did that all the sample code I found suddenly started working. All I was trying to do above was open a spreadsheet and update an existing cell. Obviously there was a lot of code missing.