0
我遇到以下與稱爲「Libro1.xlsx」的excel 2007文件相關的問題。 在這個文件上,我已經設置爲「hello world」,第一個表格中ID爲「rId1」,單元格A2爲「500」的單元格A1。用open xml sdk檢索單元格值問題
在下面的代碼中,您將看到即時訪問此工作表的每一行和單元格。即時獲取作爲輸出的單元格A2 = 500的內容,但不是A1單元格的內容(即時將「0」作爲值)。
這裏使用的是即時通訊的代碼:
' Open the document for editing.
Dim ficheroexcel As SpreadsheetDocument = SpreadsheetDocument.Open(Server.MapPath("Libro1.xlsx"), True)
Try
Dim libroconhojas As WorkbookPart = ficheroexcel.GetPartsOfType(Of WorkbookPart).First()
Dim hoja1 As WorksheetPart = libroconhojas.GetPartById("rId1")
Dim hoja2 As WorksheetPart = libroconhojas.GetPartById("rId2")
Dim hoja3 As WorksheetPart = libroconhojas.GetPartById("rId3")
'hoja.SingleCellTablePart
Dim hojadatos1 As SheetData = hoja1.Worksheet.GetFirstChild(Of SheetData)()
Dim hojadatos2 As SheetData = hoja2.Worksheet.GetFirstChild(Of SheetData)()
Dim hojadatos3 As SheetData = hoja3.Worksheet.GetFirstChild(Of SheetData)()
Dim fila As Row
Dim celda As Cell
For Each fila In hojadatos1.Elements(Of Row)()
For Each celda In fila.Elements(Of Cell)()
Response.Write("texto:" + celda.InnerText + "</br>")
Next
Next
Dim algo = ""
Catch ex As Exception
Finally
ficheroexcel.Close()
End Try
你想過爲什麼我不是得到的A1單元格設置文本任何線索?