Advertisement
2_2002-2004 Complete Applications #130993

Display Excel Spreadsheet Cell Data

This code snippet shows how to take an existing Excel 2000 document and display the cell data from different worksheets. This may work with other versions of Excel

AI

Ringkasan AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kode Sumber
original-source
'Open an Excel document, get a value from 3 cells, all on different worksheets
    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet1 As Excel._Worksheet
    Dim xlSheet2 As Excel._Worksheet
    Dim xlSheet3 As Excel._Worksheet
    Dim mytext1 As String
    Dim mytext2 As String
    Dim mytext3 As String
    xlApp = CreateObject("Excel.Application")
    xlBook = xlApp.Workbooks.Open("c:\test.xls")
    xlSheet1 = xlBook.Worksheets(1)
    xlSheet2 = xlBook.Worksheets(2)
    xlSheet3 = xlBook.Worksheets(3)

    mytext1 = xlSheet1.Range("A1").Value
    mytext2 = xlSheet2.Range("A9").Value
    mytext3 = xlSheet3.Range("C1").Value
    MessageBox.Show(mytext1 + " " + mytext2 + " " + mytext3)
    xlBook.Close()
Komentar Asli (3)
Dipulihkan dari Wayback Machine