Forms to Datagridview export to excel, Calculate and recall in another datagridview. RRS feed

  • Question

  • This concept i'm using may be odd.

    since I'm no coder and don't understand most of the coding available online im trying to simplify my calculations. So kindly help with the issue below

    Equations are available as text in datagridview1

    Eg: (0.09+32*A)*0.12 and 


    Assume All the equations are in Sheet1 and same directory of my VS solution File (Excel Name: Factors.xls)

    Now in forms i gave input Value for "A" in Textbox1 and "B" in Textbox2

    These inputs are to be exported in to Sheet2 of Factors.xls  Row[2].Cell[2] and Row[3].Cell[2].

    Note: not every cell is having formulas

    We have to use sheet3 to use values in sheet 2 convert the formulas into values and import the same to datagridview2


    is there any method i can calculate directly in Datagridview and change all cells with formulas

    Thanks in advance

    Harsha vardhan

    Saturday, January 25, 2020 8:49 AM

All replies

  • Hi,

    Sorry, I could not fully understand your requirement. Do you want to calculate the data in DataGridView1 and save it to DataGridView2?

    If so, you can use the following format to access the cell value.


    And here is the simple demo.

        private void Calculate_Click(object sender, EventArgs e)
            dataGridView2.Rows[0].Cells[1].Value = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value) + Convert.ToInt32(dataGridView1.Rows[1].Cells[1].Value);

    Hope this can help you.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Monday, January 27, 2020 2:25 AM