Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

808 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