Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2000-05-03
2
Medium Priority
?
441 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 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

877 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