Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write Macro to Fix Data Alignment (Data dump from Crystal to Excel Karin Excel Discussion (Misc queries) 2 September 22nd 09 05:31 PM
Excel 2002: How to write protect a cell using password ? Mr. Low Excel Discussion (Misc queries) 5 June 26th 07 10:55 PM
How do you write an excel formula to sum data in every second cell Sarah needs to know Excel Worksheet Functions 5 November 18th 05 05:28 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Write Data to Excel Database James W.[_2_] Excel Programming 2 January 17th 05 06:38 PM


All times are GMT +1. The time now is 12:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"