Solved

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

Posted on 2000-05-03
2
424 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

685 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