没有在Excel工作表中命名的单元格,但仍需要从单元格中获取数据

我有一个Excel 2003床单被客户使用。

我需要更新一个从这些单元格中提取数据的Delphi应用程序,但是单元格根本没有被命名,它们只是j3j55

细胞中的数据是否仍然可以发送到其他应用程序?

Delphi应用程序可以采取这些值吗?

您可以使用OLE通过Delphi处理Excel文件。

 uses ComObj; procedure TForm3.btn1Click(Sender: TObject); var ExcelApp: OleVariant; begin try ExcelApp := CreateOleObject('Excel.Application'); if not VarIsEmpty(ExcelApp) then Begin ExcelApp.Workbooks.Open('c:\yourfile.xls'); //Open File ShowMessage(ExcelApp.Range['J55', 'J55'].Value); //Extract value from Cell J55 End; finally if not VarIsEmpty(ExcelApp) then begin ExcelApp.DisplayAlerts := False; ExcelApp.Quit; end; end; end; 

再见。

当然,为什么不呢?

您可以使用Excel对象模型并使用一系列类访问单元格的内容。

VB(脚本)的例子

 dim xlApp set xlApp = CreateObject("Excel.Application") dim wkBook set wkBook = xlApp.WorkBooks.Add dim wkSheet set wkSheet = wkBook.Sheets(1) dim cell set cell = wkSheet.Cells("A1") 'get the reference to cell A1 msgbox cell.Value 

了解Excel对象模型的最好方法是
1.打开Excel
2.按ALT + F11(VBA编辑器)
3.按F2(用于对象浏览器)
4.从显示的下拉列表中selectExcel

根类是应用程序,然后事情从那里stream动。
如工作簿 – >工作表 – >工作表 – >单元格(范围)等

希望有所帮助。