Board index » cppbuilder » Inserting of an excel sheet in rich edit control.
Elizabeth
CBuilder Developer |
Elizabeth
CBuilder Developer |
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 |
Hans Galema
CBuilder Developer |
2005-08-29 08:55:18 PM
Re:Inserting of an excel sheet in rich edit control.
Elizabeth wrote:
QuoteI have inserted an excel sheet in RichEdit control. QuoteMy problem here is that if the excel sheet contains less number of rows, the QuoteWhen the excel sheet is double clicked MS Excel editor is opened and there Hans. |
Elizabeth
CBuilder Developer |
2005-08-30 12:08:24 AM
Re:Inserting of an excel sheet in rich edit control.
Please read below.
Thanks, Elizabeth "Hans Galema" < XXXX@XXXXX.COM >wrote in message QuoteElizabeth wrote: was actually an answer to one of my other problems. Quote
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 {smallsort} |
Hans Galema
CBuilder Developer |
2005-08-30 01:18:18 AM
Re:Inserting of an excel sheet in rich edit control.
Elizabeth wrote:
QuotePlease read below. about now. Quote>Please be more specific. |
liz
CBuilder Developer |
2005-08-30 01:25:49 AM
Re:Inserting of an excel sheet in rich edit control.
On Mon, 29 Aug 2005 21:38:24 +0530, Elizabeth wrote:
QuoteI need a solution where in this sheet can spread liz |
Elizabeth
CBuilder Developer |
2005-08-30 02:12:50 PM
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 QuoteElizabeth wrote: |
Elizabeth
CBuilder Developer |
2005-08-30 02:41:55 PM
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 QuotePlease refer to the following link to get the code for creating an excel |
Hans Galema
CBuilder Developer |
2005-08-30 02:43:08 PM
Re:Inserting of an excel sheet in rich edit control.
Elizabeth wrote:
QuotePlease refer to the following link to get the code for creating an excel Now what do you load in the TRichEdit ? The sheet or the .xls file ? And how ? Please show code. Hans. |
Hans Galema
CBuilder Developer |
2005-08-30 05:34:43 PM
Re:Inserting of an excel sheet in rich edit control.
Elizabeth wrote:
QuoteRefer the following link for inserting a bitmap in richedit. QuoteFrom the two links which I gave you I could create an excel file and insert 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. |
Elizabeth
CBuilder Developer |
2005-08-30 07:42:59 PM
Re:Inserting of an excel sheet in rich edit control.QuoteIn that thread you are more concerned to create an .xls file then { //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; } QuoteHans. |
Hans Galema
CBuilder Developer |
2005-08-31 05:34:08 PM
Re:Inserting of an excel sheet in rich edit control.
Elizabeth wrote:
QuoteMy problem here is that if the excel sheet contains less number of rows, the Do you mean that the TRichEdit does not provide scrollbars where excel does ? Be sure to set the richedit ScrollBars property to ssBoth. Hans. |