|
|
Hi, everyone.
I am finding solution which can use to read Excel format into MFC. I have questions in next 2cases. Answer me please.
case 1. Without MS Office package.
Although Excel isn't installed in my computer, I must read excel file into my MFC program. How can I parse this format without execl's COM interface?
case 2. importing Excel version is different.
I installed Excel 2007 into my computer, but I must read Excel 2010 file into my MFC program. If MS Office were installed in my computer, we can use to read Excel format into MFC using Excel's open COM interface. But, when supporting version is different from my version, how can I solve this problem?
|
|
|
|
|
|
You can use ODBC driver for Excel and read a data from Excel sheet by database functions (CRecordSet etc.).
|
|
|
|
|
There are four ways to read and write Excel files:
- Using Excel Automation (COM / OLE Dispatch) with the Excel type library. This requires an installed Excel on the machine running your application and the Excel type library on the development machine.
- Using ODBC. Open Database Connectivity is an operating system independent standard for database management. With Excel ODBC drivers, it can be used to read and write Excel files. Because it is a database interface, it handles sheets from an Excel file like tables in a database file. The required Excel ODBC driver is installed by the Windows Setup.
- Using ADO (OLE DB). ActiveX Data Objects is like ODBC a database interface, handling sheets from an Excel file like tables in a database file. It is more up-to-date than ODBC. This requires the ADO DLL wich is installed by Windows Setup. ADO may be also used to connect to Excel files using the ODBC drivers using a different connect string.
- Using a library that provides reading and writing Excel files.
Examples are:
- BasicExcel [^],
- ExcelFormat Library [^] (based on BasicExcel),
- LibXL (commercial) [^].
When deciding to use ODBC or ADO, ADO is preferred because the ODBC drivers has some limitations due to bugs and ADO supports accessing fields by value while ODBC only supports text strings.
To use ODBC and ADO with Excel 2007 files (XLSX), the 'Microsoft Access Database Engine 2010 Redistributable' package must be installed.
To exchange data with Excel, two additional methods using text formats can be used:
- Creating Text, CSV, RTF, or HTML files that can be opened by Excel and other spreadsheet programs or save data from within Excel in one of these formats.
- Providing Text, CSV, RTF, or HTML data for clipboard and OLE Drag&Drop operations.
With Excel 2007, the new OpenXML based file formats (mainly XLSX, XLSB, XLSM) has been introduced. Later versions use the same format. Older Office versions including the viewers can use the new format when installing the Microsoft Office Compatibility Pack.
|
|
|
|
|
Now say a very big thankyou to those two previous excellent answers....
==============================
Nothing to say.
|
|
|
|
|
Thank you very much. I recieved your solutions sufficiently. Have a nice day!
|
|
|
|
|
We are currently maintaining a Windows application (MFC). Which retrieves data
from an XML files.
The XML file contains large data to display the UI components which are
created dynamically in
the CScrollView window or class.
Under Windows XP platform the UI components can be created dynamically and
displayed in the
CScrollView properly. The UI components are so large. 504 components to be
exact. These contains buttons,
labels, edit box, spinners, comboboxes and others. The window or screen does
not get corrupted or
destroyed. The vertical scollbar works properly.
But under Windows 7 platform, the UI components are not displayed properly.
When it reach to a certain group no, the groups are overlapping other groups resulting to a bad display. The vertical scroller or scrollbar does not work properly. I already tried comparing the values that holds the sizes and ranges for scroll member variables but so far they have similar values. This program had already handled the above 32k range scroll range issue.
We are currently maintaining this project in a Visual Studio 2005 C++ project (IDE).
|
|
|
|
|
Hello,
What does it mean: "The vertical scroller or scrollbar does not work properly"? Does it mean you cannot use it? Is it disabled? or just screen is not refreshed properly?
If I understood the effect on Win7: "overlapping controls" maybe the problem is with graphics card? I know cases from my application, that on some poor graphics cards on Win7 with AERO turned on scrolling rows containing many editable controls caused strange screen effects. The solution was to update graphics card driver or turn the AERO off. It helped in all cases.
|
|
|
|
|
I think its not from the graphics card since it should only display texts. The vertical scroller is still good at the first few groups but when it reaches to a certain group, all the remaining groups are displayed at the same place overlapping each other. At first, we thought that it reached the maximum scroll range but the thing is, We already had a method that handles that exception and it worked fine in win xp environment but not in win 7.
|
|
|
|
|
In my case there were just texts too. The problem was not with advanced 3d graphics, but with srolling many controls containing simple texts. 8 columns and 20 rows each filled with one control, scrolled on Win7 with Aeoro turned on on some Intel grapcics chipset caused overlapping.
Could you show us this special method? What does it do, that problem is solved for Win XP? Maybe some methods are not supported by Win7. Or Win7 uses other dlls version, which are not good for your solution from WinXp.
|
|
|
|
|
BOOL CMyScrollView::OnScroll(UINT nScrollCode, UINT nPos, BOOL
bDoScroll)
{
SCROLLINFO info;
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_TRACKPOS;
if (LOBYTE(nScrollCode) == SB_THUMBTRACK)
{
GetScrollInfo(SB_HORZ, &info);
nPos = info.nTrackPos;
}
if (HIBYTE(nScrollCode) == SB_THUMBTRACK)
{
GetScrollInfo(SB_VERT, &info);
nPos = info.nTrackPos;
}
return CScrollView::OnScroll(nScrollCode, nPos, bDoScroll);
}
This method could be found on MSDN site which we also used. It handles the above 32k range for scrollview. One thing that I also noticed is the SB_THUMBTRACK in win7 is that, it was much bigger compared in the XP and Vista Environment. My thought is that if the SB_THUMBTRACK size varies the size of the scrollview, is it possible that some default value in win7 environment affects the maximum scrollsize range?
|
|
|
|
|
I would like to know how did you resolve the problem in your case. I might wanna try since there is still no fix yet until now. This problem is so rare that no one could relate my situation.
|
|
|
|
|
Hello,
In my case the problem was just with screen refreshing on Win7. Updating graphics card driver or turning Windows AERO off on user's computer solved the problem. So I think my case was different from yours. The only one thing is the same in our cases: WinXP worked fine, Win7 did not.
If I undarstand your app correctly, you are creating many GDI objects (many Cwnd obj.). It is a surprise for me, because normally there is a limit for GDI in application. If you reach that limit, method: CWnd::Create() fails. The value of GDI count is written in Windows registry. Unfortunately I don't remember the regkey. But I think this also not your case, since you have got probles with controls overlapping from certain point of scroll pos.
Maybe the problem is not with ScrollBar, but with scrolled out CScrollView. Maybe you have reached the end of CScrollView and your application is trying to draw all controls at the end of CScrollView?
I think you can try to change your mechanics in app. Do something like this:
Do not let your application to scroll View so far (above 32k). It is not necessary. Try to hide/delete controls, if are scrolled out from visible part of View and show/create controls, which has to be shown after scrolling.
|
|
|
|
|
Thanks for the reply. I have tried monitoring the GDI and user objects in the task manager and found out that it only consumes about 30-50 GDI objects & 1.8k-7k user objects in the page that has the bug display. It hasn't reached yet the 10k limit for the user object so it might not be the cause of the GUI problem in the scrollview. I also tried increasing the limit of the user object around 18-20k but still no effect on the output. I really hope someone has a bugfix on this. (probably microsoft)
|
|
|
|
|
Hi
My rich edit displays the text I streamed in
Somewhere in the middle of the text
I have tried various methods e.g. GetCurrentLine
LineIndex with a value of -1 to get the current line
Index to use in LineScroll to scroll back to the top
Of the rich edit but each of these methods returns
0
Any help appreciated it
|
|
|
|
|
First call LineIndex(-1) and feed that result into LineFromChar() .
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
hI
I Get Zero returned from both functions as I was tracing the return value with the value in the EAX
register
theline = myedit->LineFromChar(myedit->LineIndex(-1));
000000013FE55D61 or edx,0FFFFFFFFh
000000013FE55D64 mov rcx,qword ptr [rbx+180h]
000000013FE55D6B call CRichEditCtrl::LineIndex (13FE593C8h)
000000013FE55D70 mov rcx,qword ptr [rbx+180h]
000000013FE55D77 movsxd r9,eax
000000013FE55D7A xor r8d,r8d
000000013FE55D7D mov edx,436h
000000013FE55D82 mov rcx,qword ptr [rcx+40h]
000000013FE55D86 call qword ptr [__imp_SendMessageA (13FE719D0h)]
|
|
|
|
|
ForNow wrote: I Get Zero returned from both functions...
Does the control have multiline text in it? What line is the caret on?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
It is multiline because a whole bunch
Of text is displayed
The caret/cursor doesn't appear visually anywhere
Whitin the body of text displayed
Thanks
|
|
|
|
|
ForNow wrote: The caret/cursor doesn't appear visually anywhere Whitin the body of text displayed Which may be the problem? I just created a test project, added a rich edit control with the WS_VSCROLL , WS_HSCROLL , and ES_MULTILINE styles, and the caret was visible and moveable.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks I don't have WS_HSCROLL and WS_VSCROLL
I'll insert those styles and re-try
I am at work now will try tommorow night
Thank you very much
|
|
|
|
|
Hi
I added to ES_AUTOHSCROLL and VSCROLL
The Caret seems to appear in the middle of the text but no scrolling here is a snipet of my code
<pre lang= 'cpp'>
in CProgDebug::ONINITDIALOG
long start, end, theline;
myedit = new CProgedit; // allocate the richedit
UpdateData(FALSE); // connect to dilog object
// myedit->SetOptions(ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL);
EDITSTREAM es;
// Set the ENM_REQUESTRESIZE event flag
// myedit->SetEventMask( ENM_REQUESTRESIZE ); // set notificate to keep number of charcters in view
// Force the control to issue a EN_REQUESTRESIZE notification
// myedit->RequestResize( );
CStdioFile *fileptr = new CStdioFile;
fileptr->Open(proglisting,CFile::typeBinary);
es.dwCookie = (DWORD) fileptr;
es.dwError = 0;
es.pfnCallback = (EDITSTREAMCALLBACK) readlisting;
myedit->StreamIn(SF_TEXT, es);
myedit->SetFocus();
theline = myedit->LineFromChar(myedit->LineIndex(-1));
myedit->LineScroll(-theline,0);
myedit->HideSelection(TRUE,FALSE);
ShowWindow(SW_SHOW);
CDialog::OnInitDialog();
return TRUE;
}
</pre>
IDD_PROGDBG DIALOGEX 0, 0, 779, 345
STYLE DS_SETFONT | DS_MODALFRAME |WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Debug Dialog"
MENU IDR_HERC_CMDTYPE
FONT 8, "Times New Roman", 400, 0, 0x0
BEGIN
CONTROL "",IDC_RICHEDIT22,"RichEdit20A",WS_CHILD | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_MULTILINE | WS_BORDER | WS_TABSTOP,17,39,735,273
END
|
|
|
|
|
I am trying to figure out how to create a emulator that loads multiple generic hid mouse devices in c (or generic mouse devices). Generic drivers are ones that are included with windows already. Anyone know where I should start or if this would be a hard task?
The end result is to make a c driver that emulates mouse input like the sendinput api except with multiple mouse devices.
The programs I was trying to get this to work in are: programs created with Microsoft multipoint sdk and Microsoft mouse mischief.
So far I do not have a c driver but have the technical details of the device on my project page (I want to get rid of dsf since its not 64-bit compatible): http://kinectmultipoint.codeplex.com. The emulator on the project does work now but I want to try and code a better system in.
jeffery
|
|
|
|
|
Hello Every one,
I am adding some key in Registry is not getting into effect until system reboot or by killing explorer.
so how can i achieve it, without rebooting and killing explorer.
please help me out ..
Regards
sarfaraz
|
|
|
|