Board index » cppbuilder » Inserting of an excel sheet in rich edit control.

Inserting of an excel sheet in rich edit control.


2005-08-29 05:27:45 PM
cppbuilder29
Hi All,
I have inserted an excel sheet in RichEdit control.
My problem here is that if the excel sheet contains less number of rows, the
sheet can be viewed in one page of Richedit control, but if more rows are
present, the sheet cannot be viewed completely.
When the excel sheet is double clicked MS Excel editor is opened and there
the sheet can be viewed completely.
Is there any way to extend the sheet to two or more pages of the richedit
control ?
Thanks,
Elizabeth
 
 

Re:Inserting of an excel sheet in rich edit control.

Elizabeth wrote:
Quote
I have inserted an excel sheet in RichEdit control.
Could you explain what you consider to be an excel sheet and show
the code where you insert such a thing in a TRichEdit control ?
Quote
My problem here is that if the excel sheet contains less number of rows, the
sheet can be viewed in one page of Richedit control, but if more rows are
present, the sheet cannot be viewed completely.
With 'less' you mean 'a few' ? Looks normal behaviour to me. Of a long
text you will see only one page also.
Quote
When the excel sheet is double clicked MS Excel editor is opened and there
the sheet can be viewed completely.
Doubleclicked where ? It would show 10000 rows ?
Please be more specific.
Hans.
 

Re:Inserting of an excel sheet in rich edit control.

Please read below.
Thanks,
Elizabeth
"Hans Galema" < XXXX@XXXXX.COM >wrote in message
Quote
Elizabeth wrote:

>I have inserted an excel sheet in RichEdit control.

Could you explain what you consider to be an excel sheet and show
the code where you insert such a thing in a TRichEdit control ?
>>>>>>>>>>>>>>>>>Inserting of excel sheet is creating an excel
application with one sheet in it and inserting this Excel
application. I have done this by the code posted on this group itself, which
was actually an answer to one of my other problems.
Quote

>My problem here is that if the excel sheet contains less number of rows,
the
>sheet can be viewed in one page of Richedit control, but if more rows
are
>present, the sheet cannot be viewed completely.

With 'less' you mean 'a few' ? Looks normal behaviour to me. Of a long
text you will see only one page also.
>>>>>>>>>>If the sheet which gets inserted contains some specific number
of rows, this sheet can be seen in one page of rtf.
But if the sheet contains more number of rows then
it tries to fit in one page of the rtf, and hence is not able to display all
the rows.
I need a solution where in this sheet can spread
over more than 2 pages of rtf.
Quote
>When the excel sheet is double clicked MS Excel editor is opened and
there
>the sheet can be viewed completely.

Doubleclicked where ? It would show 10000 rows ?
>>>>>>>>>By 'double clicking' I mean 'double clicking' this inserted sheet.

Please be more specific.

Hans.
 

{smallsort}

Re:Inserting of an excel sheet in rich edit control.

Elizabeth wrote:
Quote
Please read below.
You have a way of replying that makes your reply unreadable
for me. Furthermore I don't understand where you are talking
about now.
Quote
>Please be more specific.
Just answer the simple questions. Ans show some code.
Hans.
 

Re:Inserting of an excel sheet in rich edit control.

On Mon, 29 Aug 2005 21:38:24 +0530, Elizabeth wrote:
Quote
I need a solution where in this sheet can spread
over more than 2 pages of rtf.
try the delphi.oleautomation newsgroup
--
liz
 

Re:Inserting of an excel sheet in rich edit control.

Please refer to the following link to get the code for creating an excel
sheet
groups.google.co.in/group/borland.public.cppbuilder.vcl.components.using/browse_thread/thread/38781fca0732e36c/7bb21295c8d6058f
"Hans Galema" < XXXX@XXXXX.COM >wrote in message
Quote
Elizabeth wrote:
>Please read below.

You have a way of replying that makes your reply unreadable
for me. Furthermore I don't understand where you are talking
about now.

>>Please be more specific.

Just answer the simple questions. Ans show some code.

Hans.
 

Re:Inserting of an excel sheet in rich edit control.

Now ,
Refer the following link for inserting a bitmap in richedit.
home.att.net/~robertdunn/Yacs.html#CodeSection
Instead of a bitmap file, I have inserted and excel file".xls".
From the two links which I gave you I could create an excel file and insert
it in richedit.
Thanks,
Elizabeth.
"Elizabeth" < XXXX@XXXXX.COM >wrote in message
Quote
Please refer to the following link to get the code for creating an excel
sheet

groups.google.co.in/group/borland.public.cppbuilder.vcl.components.using/browse_thread/thread/38781fca0732e36c/7bb21295c8d6058f


"Hans Galema" < XXXX@XXXXX.COM >wrote in message
news:43134339$ XXXX@XXXXX.COM ...
>Elizabeth wrote:
>>Please read below.
>
>You have a way of replying that makes your reply unreadable
>for me. Furthermore I don't understand where you are talking
>about now.
>
>>>Please be more specific.
>
>Just answer the simple questions. Ans show some code.
>
>Hans.


 

Re:Inserting of an excel sheet in rich edit control.

Elizabeth wrote:
Quote
Please refer to the following link to get the code for creating an excel
sheet
groups.google.co.in/group/borland.public.cppbuilder.vcl.components.using/browse_thread/thread/38781fca0732e36c/7bb21295c8d6058f
In that thread you are more concerned to create an .xls file then
creating a sheet.
Now what do you load in the TRichEdit ? The sheet or the .xls file ?
And how ? Please show code.
Hans.
 

Re:Inserting of an excel sheet in rich edit control.

Elizabeth wrote:
Quote
Refer the following link for inserting a bitmap in richedit.
home.att.net/~robertdunn/Yacs.html#CodeSection

Instead of a bitmap file, I have inserted and excel file".xls".
Finally you come with real info. Did you change Robert's code for that?
Quote
From the two links which I gave you I could create an excel file and insert
it in richedit.
The creation of an .xls file is a complete other project and does
not look relevant for your problem which is "a not complete display of
an .xls file when inserted in a TRichEdit a la Robert Dunn".
Never experimented with that. I suggest you post two .xls files to the
attachments newsgroup (one that displays ok and one that does not) and
the files for a unit which contains a TForm with a TRichEdit and all
the code to insert the .xls.
Hans.
 

Re:Inserting of an excel sheet in rich edit control.

Quote
In that thread you are more concerned to create an .xls file then
creating a sheet.

Now what do you load in the TRichEdit ? The sheet or the .xls file ?
And how ? Please show code.
The code for inserting the excel file is as follows.
bool InsertFile()
{
//Inserting an excel sheet
//Pointer to the IRichEditOle interface of the rich edit control.
LPRICHEDITOLE m_pRichEditOle;
//Pointer to the embedded object.
LPOLEOBJECT m_lpObject;
//Pointer to the storage.
LPSTORAGE m_lpStorage;
//Pointer to the clientsite.
LPOLECLIENTSITE m_lpClientSite;
LPLOCKBYTES lpLockBytes = NULL;
CLSID clsid = CLSID_NULL;
OLERENDER render = OLERENDER_DRAW;
CLIPFORMAT cfFormat = 0;
LPFORMATETC lpFormatEtc = NULL;
//Getting the pointer for IRichEditOle from the richedit control
//::SendMessage(RichEditSS->Handle, EM_SETOLECALLBACK, 0,
(LPARAM)m_pRichEditOle);
if (!::SendMessage(RichEditSS->Handle, EM_GETOLEINTERFACE, 0, (LPARAM)
&m_pRichEditOle))
m_pRichEditOle = 0;
//Creating storage for the object
HRESULT hr;
hr = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (FAILED(hr))
return false;
hr = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_READWRITE, 0, &m_lpStorage);
lpLockBytes->Release();
//--------------------------------------------------------------------------
// fill in FORMATETC struct
FORMATETC formatEtc;
lpFormatEtc = &formatEtc;
lpFormatEtc->cfFormat = cfFormat;
lpFormatEtc->ptd = NULL;
lpFormatEtc->dwAspect = DVASPECT_CONTENT;
lpFormatEtc->lindex = -1;
lpFormatEtc->tymed = TYMED_NULL;
//Converting
//LPCOLESTR lpszFileName =OLESTR("C:\\Program
Files\\Borland\\CBuilder6\\Projects\\Temporary\\ExcelSheetProgrammatically\\
NewTestExcel.xls");
//LPCOLESTR lpszFileName =OLESTR("c:\\NewTestExcel.xls");
//File to be inserted.
AnsiString asXLSFileName("c:\\NewTestExcel.xls");
size_t size = asXLSFileName.Length();
LPOLESTR lpszFileName = new OLECHAR[size];
//wmemset(lpszFileName, 0 , size);
mbstowcs(lpszFileName, asXLSFileName.c_str(), size);
// attempt to create the object(to get the client site)
m_pRichEditOle->GetClientSite(&m_lpClientSite);
hr = ::OleCreateFromFile(clsid, lpszFileName,
IID_IUnknown, OLERENDER_DRAW, lpFormatEtc, m_lpClientSite, m_lpStorage,
(void**)&m_lpObject);
if (FAILED(hr))
return false;
// m_lpObject is currently an IUnknown, convert to IOleObject
if (m_lpObject != NULL)
{
LPUNKNOWN lpUnk = m_lpObject;
lpUnk->QueryInterface(IID_IOleObject, (void**)&m_lpObject);
lpUnk->Release();
if (m_lpObject == NULL)
return false;
}
// all items are "contained" -- this makes our reference to this object
// weak -- which is needed for links to embedding silent update.
OleSetContainedObject(m_lpObject, TRUE);
//Forming the REOBJECT Structure. This structure contains the
information about the object.
REOBJECT reobject;
//ZeroMemory(&reobject, sizeof(REOBJECT));
::memset(&reobject, 0, sizeof(reobject));
reobject.cbStruct = sizeof(REOBJECT);
//CLSID clsid;
hr = m_lpObject->GetUserClassID(&clsid);
if (FAILED(hr))
return false;
reobject.clsid = clsid;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.dwFlags = REO_DYNAMICSIZE;
reobject.dwUser = 0;
reobject.poleobj = m_lpObject;
//ASSERT(m_lpClientSite != NULL);
reobject.polesite = m_lpClientSite;
//ASSERT(m_lpStorage != NULL);
reobject.pstg = m_lpStorage;
//Size of the rectangle window.
SIZEL sizel;
sizel.cx = sizel.cy = 0;
reobject.sizel = sizel;
//finally inserting the object
m_pRichEditOle->InsertObject(&reobject);
DeleteFile("c:\\NewTestExcel.xls");
delete [] lpszFileName;
}
Quote
Hans.
 

Re:Inserting of an excel sheet in rich edit control.

Elizabeth wrote:
Quote
My problem here is that if the excel sheet contains less number of rows, the
sheet can be viewed in one page of Richedit control, but if more rows are
present, the sheet cannot be viewed completely.
When the excel sheet is double clicked MS Excel editor is opened and there
the sheet can be viewed completely.
40.000 rows can never be viewed at once. So what do you mean with that ?
(I asked this before!).
Do you mean that the TRichEdit does not provide scrollbars where
excel does ?
Be sure to set the richedit ScrollBars property to ssBoth.
Hans.