none
VB.NET Excel Interop "AutoSum" via automation?

คำตอบ

  • Hi REDTAIL_CODEGUY,

    Welcome to the MSDN forum.

    I’m afraid that there is no AutoSum method in Excel. It is used to describe that Excel can add some selected number using the sum formula. Here is code about opening the Text.xlsx document, calculate the number form D1 to D6 and save the result in A1.

       Dim xlApp = New Excel.Application With {.Visible = False}
            Dim xlBook = xlApp.Workbooks.Open("D:\Text.xlsx")
            Dim xlSheet = DirectCast(xlBook.Worksheets(1), Excel.Worksheet)
            Dim a As Range = xlSheet.Range("A1")
            a.Formula = "=SUM(D1:D6)"
            xlBook.Close(SaveChanges:=True)
            xlApp.Quit()
            xlApp = Nothing
    
    If you have any additional questions, please feel free to let we know.


    Mark Liu-lxf [MSFT]
    MSDN Community Support | Feedback to us
    • ทำเครื่องหมายเป็นคำตอบโดย REDTAIL_CODEGUY 24 พฤศจิกายน 2554 14:28
    24 พฤศจิกายน 2554 11:25

ตอบทั้งหมด