Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Excel PIA C# - Format a Cell

14 views
Skip to first unread message

Mike Strieder

unread,
Jan 24, 2004, 2:14:14 PM1/24/04
to
Hi,

thx for reading this entry and for your help

I select a cell in Excel (C#) and want to set the Text "ABC123". But in this
Cell the Text "123" should appear in Bold!
How can this work ???

Ciao Mike

ExcelApplication excel = new
ExcelApplication();excel.Workbooks.Open(@"c:\temp\xx.xls",Missing.Value,Miss
ing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Va
lue,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Mi
ssing.Value,Missing.Value); Worksheet wks = (Worksheet)excel.Sheets["test"];
Range r = wks.get_Range("A17", Missing.Value);
... ????


Peter Huang

unread,
Jan 26, 2004, 4:27:10 AM1/26/04
to
Hi Mike,

Thanks for posting in the community. My name is Peter, and I will be
assisting you on this issue.

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to automation the Excel
from C#, and need to set the value and format of a cell.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Here I write the code for you , you may have a try and let me know the
result.

using System;
using Excel=Microsoft.Office.Interop.Excel;
using System.Reflection;
class Class
{
[STAThread]
static void Main(string[] args)
{
Excel.Application exApp = new Excel.ApplicationClass();
exApp.Visible=true;

exApp.Workbooks.Open(@"c:\test.xls",Missing.Value,Missing.Value,Missing.Valu
e,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Miss
ing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Va
lue);
Excel.Worksheet wks = (Excel.Worksheet)exApp.Sheets["test"];
wks.get_Range("A17",Missing.Value ).set_Value(Missing.Value,"123456");
wks.get_Range("A17",Missing.Value ).Font.Bold=true;
}

Please Apply My Suggestion Above And Let Me Know If It Helps Resolve Your
Problem.

However, if the problem still persists, please help me collect more
information for further troubleshooting.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Shawn

unread,
Dec 9, 2004, 12:42:59 PM12/9/04
to
Hi,

Do you know of a way I can extract the different fonts within a Cells
Value?

0 new messages