Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Infragistics Excel formula Query
posted

Hi,

We are using Infragistics Excel control, facing some issue how to copy First row formulas to all other rows with cell increment eg.

First Row formulas

K1=IF(D1="96","",A1)    L1=IF(D1="96","",B1) ,etc.,

same apply to 

K-L column copy for all rows having 1046 rows. formula should change all cell with row id eg K2 should have

K2=IF(D2="96","",A2)    L2=IF(D2="96","",B2) ,etc.,

Note: please share code sample with VB.net

Thanks,

Kumaran Krishnamurthi

  • 34430
    Offline posted

    Hello Kumaran,

    There does not exist a built-in way to copy a formula to each row of a Worksheet with a cell increment, but this behavior could be easily achieved using a loop. For example, the following code would achieve one of your “IF” formulas for the first 1046 cells:

            Dim workbook As Workbook = New Workbook(WorkbookFormat.Excel2007)
            Dim sheet As Worksheet = workbook.Sheets.Add("Sheet1", SheetType.Worksheet)
    
            For i As Integer = 1 To 1046 - 1
                Dim cell As WorksheetCell = sheet.GetCell("K" & i.ToString())
                Dim formulaString As String = "=IF(D" & i.ToString() & "=" & """96""" & "," & """""" & ",A" & i.ToString() & ")"
                cell.ApplyFormula(formulaString)
            Next

    I hope this helps you. Please let me know if you have any other questions or concerns on this matter.

  • 0
    Offline posted

    Imports Excel = Microsoft.Office.Interop.Excel

    Public Class Form1

    Private Sub CopyFormulas()
    ' Initialize Excel Application
    Dim excelApp As New Excel.Application()
    Dim workbook As Excel.Workbook = excelApp.Workbooks.Open("YourExcelFile.xlsx")
    Dim worksheet As Excel.Worksheet = workbook.Sheets("YourSheetName")

    ' Get the range of your data (assuming it starts from column A and ends at column L, and has 1046 rows)
    Dim dataRange As Excel.Range = worksheet.Range("A1:L1046")

    ' Copy formulas from the first row to all other rows with cell increment
    For i As Integer = 2 To dataRange.Rows.Count
    For j As Integer = 1 To dataRange.Columns.Count
    ' Get the formula of the cell in the first row and replace the row number with the current row number
    Dim formula As String = worksheet.Cells(1, j).Formula
    formula = formula.Replace("1", i.ToString())

    ' Apply the modified formula to the current cell
    worksheet.Cells(i, j).Formula = formula
    Next
    Next

    ' Save and close the workbook
    workbook.Save()
    workbook.Close()
    excelApp.Quit()

    ' Release Excel objects
    ReleaseComObject(worksheet)
    ReleaseComObject(workbook)
    ReleaseComObject(excelApp)

    MessageBox.Show("Formulas copied successfully.")
    End Sub

    Private Sub ReleaseComObject(ByVal obj As Object)
    Try
    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
    obj = Nothing
    Catch ex As Exception
    obj = Nothing
    Finally
    GC.Collect()
    End Try
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    CopyFormulas()
    End Sub
    End Class

    scratch geometry dash

  • 0
    Offline posted

    Hii everyone

    To solve the problem of Infragistics Excel controlwe need to use the to copy the formula from the first row to all other rows with cell increments:

    Get the formula from the first row.
    Repeat each next row.
    Update the formula in each cell to adjust cell references based on the row index.
    Apply the update formula to the corresponding cell in each row.
    Be sure to handle any edge cases or special conditions specific to your implementation.

  • 0
    Offline posted in reply to Andrew Goldenbaum

    Interested in flirting with attractive girls? Hiring Independent Delhi Escorts might just be what's needed. These girls make great partners during bed or other sensual activities. These gorgeous women can accompany you on visits to restaurants, discos, pubs, and travel companions during an extended vacation. Model Delhi Escort Service are some of the sexiest women around. With stunning eyes and delicate lips, model escorts provide excellent services from Escort Service Delhi's beautiful girls, ensuring clients enjoy themselves and offering massages or sexual pleasure services when requested.