private void button1_Click(object sender, EventArgs e) { int row; int col; int.TryParse(textBoxRow.Text, out row); int.TryParse(textBoxCol.Text, out col); int sheetRow = 0; int sheetCol = 0; int sheetIndex; string translateText; string[] AllSheets = inputFileXls.AllSheets; int NumSheets = AllSheets.Length; for (sheetIndex = 3; sheetIndex <= NumSheets; sheetIndex++) { // output and input focus on sheet inputFileXls.SelectSheet(AllSheets[sheetIndex - 1]); outputFileXls.SelectSheet(AllSheets[sheetIndex - 1]); // Get row and col of sheet inputFileXls.GetRowCol(ref sheetRow, ref sheetCol); for (row = 1; row <= sheetRow; row++) { for (col = 1; col <= sheetCol; col++) { string value = inputFileXls.CellValues(row, col); translateText = translator.Translate(value, comboBoxLangSrc.Text, comboBoxLangDst.Text); textBoxDebug.Text = translateText; outputFileXls.SetCellValues(row, col, translateText); Thread.Sleep(3000); } } } outputFileXls.SaveAs("Translated Testcase.xlsx"); MessageBox.Show("Translate done"); }