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.

Tue Nov 20, 2018 1:15 pm

Sorry I have so many questions.

Is there any way to determine if a value in a cell has changed?

GH

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

Wed Nov 21, 2018 7:44 am

Hi,

Thanks for you inquiry.
After investigation, I'm sorry to tell that there is no direct method to determine if a value in a cell has changed in Spire.Spreadsheet. The only way is to compare the original cell value with the current one like below.
Code: Select all
    Dim originalSheet(,) As String
    Private Sub LoadFile_Click(sender As Object, e As EventArgs) Handles LoadFile.Click
        Dim ofDialog As OpenFileDialog = New OpenFileDialog()
        ofDialog.Filter = "All files|*.*|Micellosoft Excel Files(*.xls;*.xlsx;*.ods;*.xlsb)|*.xls;*.xlsx;*.xlsb;*.ods"
        If ofDialog.ShowDialog() = DialogResult.OK Then
            Spreadsheet1.LoadFromFile(ofDialog.FileName)
            Dim sheet As IWorksheet = Spreadsheet1.ActiveWorksheet
            Dim col As Integer = sheet.ColumnCount
            Dim row As Integer = sheet.RowCount
            ReDim originalSheet(row, col)
            Dim i As Integer = 0
            Do While (i < row)
                Dim j As Integer = 0
                Do While (j < col)
                    If (Not (sheet(i, j).Value) Is Nothing) Then
                        originalSheet(i, j) = sheet(i, j).Value.ToString
                    End If
                    j = (j + 1)
                Loop
                i = (i + 1)
            Loop
        End If
    End Sub
    Private Sub CheckCell_Click(sender As Object, e As EventArgs) Handles CheckCell.Click
        Dim sheet As IWorksheet = Spreadsheet1.ActiveWorksheet
        Dim cell As CellAdressInfo = sheet.ActiveCellAdressInfo
        If (Not (sheet(cell.Row, cell.Column).Value) Is Nothing) Then
            If Not sheet(cell.Row, cell.Column).Value.ToString.Equals(originalSheet(cell.Row, cell.Column)) Then
                MessageBox.Show("cell has changed !!!")
            Else
                MessageBox.Show("cell has not changed !!!")
            End If
        ElseIf (Not (originalSheet(cell.Row, cell.Column)) Is Nothing) Then
            MessageBox.Show("cell has changed !!!")
        Else
            MessageBox.Show("cell has not changed !!!")
        End If
    End Sub
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Wed Nov 21, 2018 8:57 am

Thank you,
It's not perfekt, but a nice workearound
GH

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

Wed Nov 21, 2018 9:51 am

Hi,

Thanks for your feedback.
Any question, feel free to contact us.
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Return to Spire.Spreadsheet