Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Worksheet ws= (Worksheet)wb.Worksheets[1];
Excel.Worksheet ws2 = wb.Sheets.Add(missing, missing, 1, missing)
            as Excel.Worksheet;
ws.get_Range("A1", "K2").Merge(true);
ws.get_Range("A1", "K2").Font.Name = "Times New Roman";
ws.get_Range("A1", "K2").Font.Size = "14";
ws.get_Range("A1", "K2").Font.Bold = true;
ws.get_Range("A1", "K2").FillLeft();
ws.Cells[2, 1] = "Line Chart Summary-BOTTOM";

here i create two work sheet.one is ws another one is ws1.
above i using ws as object name .i want to change ws to ws1 using C# coding.
C#
ws1.get_Range("A1", "K2").Merge(true);
ws1.get_Range("A1", "K2").Font.Name = "Times New Roman";
ws1.get_Range("A1", "K2").Font.Size = "14";
ws1.get_Range("A1", "K2").Font.Bold = true;
ws1.get_Range("A1", "K2").FillLeft();
ws1.Cells[2, 1] = "Line Chart Summary-BOTTOM";// Like this i want to change.

Using C# in .NET 3.5 with Visual Studio 2008, I am trying to set focus (or activate) a specific worksheet in an open workbook.for one user i use object ws another user i use object ws1 so i want to dynamically change the worksheet object.
Posted
Updated 22-Jun-14 22:47pm
v2
Comments
Rob Branaghan 23-Jun-14 16:54pm    
Hi, So you are wanting to tell ws1 that it is a specific sheet by name?
gggustafson 23-Jun-14 17:56pm    
What is the problem?
Nathan Minier 24-Jun-14 8:35am    
I'd suggest that you look at the OpenXML [^] namespace to work on your Excel documents; MS is moving support in that direction from the InterOp library, which has been fairly inconsistent across releases. There are also better tools in there for enumerating and manipulating nodes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900