Solved

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

Posted on 2000-05-03
2
392 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
Comment Utility
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
Comment Utility
2 others Excel OLE automation questions are waiting answers.
It's urgent, i'm lost...
Thanks.
David.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

771 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

13 Experts available now in Live!

Get 1:1 Help Now