Spire.Spreadsheet is a powerful component to view spreadsheet. As a standalone spreadsheet class library, Spire.Spreadsheet is a companion component to Spire.XLS, which mainly focus on how to display spreadsheet.

Fri Oct 19, 2018 2:30 pm

Hey
I want to update only the cell after set value to actual date

spreadsheet1.LoadFromFile(Datei)
dim Sheet As Spire.Spreadsheet.Forms.IWorksheet = spreadsheet1.ActiveWorksheet
Dim ColRow As CellAdressInfo = Sheet.ActiveCellAdressInfo
Sheet.Item(ColRow.Row, ColRow.Column).SetCellValue(Format(Now, "HH:mm"))
'spreadsheet1.Refresh()

the problem is if I use 'spreadsheet1.Refresh() the spreasheetviewer scrolls to the first row.

thank you GH

GHWels
 
Posts: 90
Joined: Sun Nov 23, 2014 7:22 pm

Mon Oct 22, 2018 6:24 am

Hello,

Thank you for contacting us.
Kindly note that the default active cell is the first cell when opening an Excel file with Spire.Spreadsheet. You could refer to below code to change the active cell and update it. If there is any question, just feel free to write back.
Code: Select all
Private Sub OpenFile_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Spreadsheet1.LoadFromFile("test.xlsx")
End Sub

Private Sub updateTimw_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Dim sheet As Spire.Spreadsheet.Forms.IWorksheet = Spreadsheet1.ActiveWorksheet
    Dim ColRow As CellAdressInfo = sheet.ActiveCellAdressInfo
    sheet.Item(ColRow.Row, ColRow.Column).SetCellValue(Format(Now, "HH:mm"))
    Spreadsheet1.Refresh()
End Sub


Sincerely,
Lisa
E-iceblue support team
Last edited by Lisa.Li on Mon Oct 22, 2018 10:58 am, edited 1 time in total.
User avatar

Lisa.Li
 
Posts: 1270
Joined: Wed Apr 25, 2018 3:20 am

Mon Oct 22, 2018 8:34 am

Sorry I solved the problem!

Only "Spreadsheet1.Refresh()" scolls the Sheet to the TOP.
With "Sheet.SetActiveCell(ColRow)" I jump back to the CELL

Private Sub updateTimw_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim sheet As Spire.Spreadsheet.Forms.IWorksheet = Spreadsheet1.ActiveWorksheet
Dim ColRow As CellAdressInfo = sheet.ActiveCellAdressInfo
sheet.Item(ColRow.Row, ColRow.Column).SetCellValue(Format(Now, "HH:mm"))
Spreadsheet1.Refresh()
Sheet.SetActiveCell(ColRow)
End Sub

Thank you
GH

GHWels
 
Posts: 90
Joined: Sun Nov 23, 2014 7:22 pm

Mon Oct 22, 2018 9:58 am

Dear,

Thanks for quick response.
Glad to hear that you resolved the issue. Any question, just feel free to contact us.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1270
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Spreadsheet