473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Excel PIA C# - Format a Cell

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.Valu e,Missing.Value,Missing.Va
lue,Missing.Value,Missing.Value,Missing.Value,Miss ing.Value,Missing.Value,Mi
ssing.Value,Missing.Value); Worksheet wks = (Worksheet)excel.Sheets["test"];
Range r = wks.get_Range("A17", Missing.Value);
.... ????


Nov 15 '05 #1
2 8894
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,Missin g.Value,Missing.Value,Miss
ing.Value,Missing.Value,Missing.Value,Missing.Valu e,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.

Nov 15 '05 #2
Hi,

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

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
3
by: Otie | last post by:
I am trying to copy the cell contents in an MSFLXGRD control (using VB5) into Excel, retaining the foreground colors of the text and numbers. I have tried using the Clipboard.SetText...
2
by: Kumar | last post by:
Hi Folks, I have a question regarding my windows c# application. This application just reads MS Excel file and puts the data in to sql server database. In that excel file ,it has one named cell...
0
by: Peter | last post by:
I am having a problem reading an Excel file that is XML based. The directory I am reading contains Excel files that can be of two types. Either generic Microsoft based or XML based. I am reading...
6
by: Kevin Humphreys | last post by:
Hi There, I am trying to export a recordset to an excel file using the Content Type below in the header. Response.ContentType = "application/vnd.ms-excel" Which works fine however the...
2
by: Brian Parker | last post by:
I need to format text in cell in an Excel worksheet and I need to do this using C#. I've seen code that will set the format for the whole cell, but I just need to format one character in that...
4
by: wellscrambled | last post by:
Folks, Probably don't have the right forum here, but this is all a bit new to me. I have a web site that sends me a daily email with an excel spreadsheet attachment that contains some customer...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
20
by: Marin Brkic | last post by:
Hello all, please, let me apologize in advance. English is not my first language (not even my second one), so excuse any errors with which I'm about to embarass myself in front of the general...
2
by: ravir81 | last post by:
Hi, I am working on excel reporting using Perl. I am facing problem with writing the header part only once for all the excels created using Perl. Here is the code : ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.