Its Ok I am success to solve this problem... :) :)
with the help of lt
FolderBrowserDialog
We can open file dialog and send this path to private
object m_strSampleFolder = Application.StartupPath + "\\ExcelData\\" ;
Like This
private Excel.Application m_objExcel = null;
private Excel.Workbooks m_objBooks = null;
private Excel._Workbook m_objBook = null;
private Excel.Sheets m_objSheets = null;
private Excel._Worksheet m_objSheet = null;
private Excel.Range m_objRange = null;
private Excel.Font m_objFont = null;
private Excel.QueryTables m_objQryTables = null;
private Excel._QueryTable m_objQryTable = null;
string path11;
private object m_objOpt = System.Reflection.Missing.Value;
private object m_strSampleFolder ;
private void Button3_Click(object sender, EventArgs e)
{
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
{
this.textBox3.Text = folderBrowserDialog1.SelectedPath;
}
path11 = textBox3.Text;
m_strSampleFolder = path11.ToString()+ "\\" ";
xlsheet();
}
private void xlsheet()
{
// Start a new workbook in Excel.
m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));
m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1));
// Create an array for the headers and add it to cells A1:C1.
object[] objHeaders = { "X-Axis CH1", "Y-Axis CH1","Nilesh", "X-Axis CH2", "Y-Axis CH2" };
m_objRange = m_objSheet.get_Range("A1", "E1");
m_objRange.set_Value(m_objOpt, objHeaders);
m_objFont = m_objRange.Font;
m_objFont.Bold = true;
// Create an array with 3 columns and 100 rows and add it to
// the worksheet starting at cell A2.
object[,] objData = new Object[bufn.Length, 5];
Int64 c_xl1 = 0, c_xl2=0;
for (int r = 0; r < bufn.Length; r++)
{
objData[r, 0] = c_xl1.ToString();
objData[r, 1] = (bufn[r] + vsc2).ToString();
c_xl1 += 1;
objData[r, 3] = c_xl2.ToString();
objData[r, 4] = (bufb[r] + vsc4).ToString();
c_xl2 += 1;
}
m_objRange = m_objSheet.get_Range("A2", m_objOpt);
m_objRange = m_objRange.get_Resize(bufn.Length, 5);
m_objRange.set_Value(m_objOpt, objData);
// Save the workbook and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + nm.ToString() + "Book24.xlsx", m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);
m_objExcel.Quit();
nm += 1;
}
Thanks to My self
Regards
Nilesh :thumbsup: