![]() |
how can use C# write data into excel with password?
I can write data into excel without password:
objBook = objBooks.Add("D:\\1.xls"); objSheets = objBook.Worksheets; objSheet = (Excel._Worksheet)objSheets.get_Item(1); //Get the range where the starting cell has the address //m_sStartingCell and its dimensions are m_iNumRows x m_iNumCols. range = objSheet.get_Range("G1", Missing.Value); range = range.get_Resize(1,1); if (this.FillWithStrings.Checked == false) { //Create an array. double[,] saRet = new double[1,1]; //Fill the array.for (long iRow = 0; iRow < 1; iRow++) { { for (long iCol = 0; iCol < 1; iCol++)//Put a counter in the cell. saRet[iRow, iCol] = iRow * iCol; } } //Set the range value to the array. range.set_Value(Missing.Value, saRet ); } objApp.Visible = false; objApp.UserControl = true; // Save the workbook and quit Excel. objBook.SaveAs("D:\\1.xls", m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt); objBook.Close(false, m_objOpt, m_objOpt); objApp.Quit(); but if the excel have password,I cant do. thanks! |
All times are GMT +1. The time now is 05:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com