English 中文(简体)
无需在Excel表上标明但仍然需要从单元中收集数据的单元
原标题:Cells not named in Excel sheets but still the Data from Cells need to be taken
  • 时间:2009-09-25 17:09:41
  •  标签:

我有一份客户使用的Excel 2003表。

我需要更新从这些细胞中提取数据的Delphi应用程序,但是这些细胞根本不命名,只是j3j55

牢房的数据是否仍可与其他应用相传?

德尔菲的应用能否达到这些价值?

最佳回答

你们可以通过使用OLE处理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;

页: 1

问题回答

Sure,为什么不?

您可使用Excel Object Model &利用一系列班级查阅小组的内容。

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

The best way to learn about Excel object model is to
1. Open Excel
2. Press ALT + F11 (VBA editor)
3. Press F2 (for object browser)
4. Choose Excel from the dropdown where it shows

The root class is Application & then things flow from there.
e.g. WorkBook -> WorkSheets -> Worksheet -> Cells (Range) etc.

希望会有所帮助。





相关问题
热门标签