Solved

Urgent! Excel OLE: How to format a cell to text only ?

Posted on 2000-05-03
2
402 Views
Last Modified: 2013-11-25
Hi all,
I wan't to display a *string* in an Excel cell, using MFC OLE
Automation.
When I use this kind of string "david", "A7.1", all is fine.

But when I want to display those kind of strings:  "1.20", "1.55",
"0.77" Excel translates them automatically in integers, and displays
these string in "1,20", "1,55", "0,77" (the dot is translated in
comma)... (I am using a French version of Excel)

At this time I use the following way to send datas to excel:
CString strText="1.20";
LPDISPATCH lpDisp;
 lpDisp=sheet.GetRange(COleVariant("A1"), COleVariant("A1")); // Select
the A1 cell
 ASSERT(lpDisp);
 range.AttachDispatch(lpDisp);
 range.SetValue(COleVariant(strText)); // <--- Excel display  1,20 !!!

How can I Force Excel to write a STRING to a specific cell ? And solve this problem!

Thanks for all, it's urgent!

David.

0
Comment
Question by:tradinfo
2 Comments
 

Accepted Solution

by:
bxt earned 50 total points
ID: 2773686
Try using this line for your string definition instead (where a single quote immediately follows the first double quote)


CString strText="'1.20";
0
 

Author Comment

by:tradinfo
ID: 2776479
2 others Excel OLE automation questions are waiting answers.
It's urgent, i'm lost...
Thanks.
David.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now