|
|
Comments and Discussions
|
|
 |
|

|
Hi Andrei,
thanks for your code it was been very usefull for my application.
It's not clear how I can made a cell with attributes BOLD or COLOR; I've tried many and many times without results.
Can you help me?
Thanks
Ale
|
|
|
|

|
Hi Andrei,
I want to save date and time in my excel file. How to do using your miniexcel?
|
|
|
|
|

|
it´s not free...
|
|
|
|

|
Hi,
i want to write into the fiel more then one time.
For example:
I write some strings into the File.
And via one for loop, i will write at the end of file with miniexcel.write(f).
But this doesn't work.
Has anybody an idea?
Greets
|
|
|
|

|
Hi Andrei ,
Thanks for your information and thid file.
but i used your concept in my project , but my system hanging after i run 10 min..
just the normal error(system.exe encounterd a problem)comes out..
afterthat if restart , then it works fine..
i couldn't findout where id the problem exactly..
the following code u sed your function.. i just stored the listview result into excel worksheet..
please have a look at code, and reply me what is the mistake i made?? i already include your headerand .cpp file..i used to store in .csv file..
please why system hang some times..??
void CResultList::saveTest()
{
int m = 0 ;
CTime time= CTime::GetCurrentTime();
CString s = time.Format( "%H, %M, %d, %Y" );
CString filename;
char newline = '\n';
filename = "C:\\Data\\MODEL"+ m_modelName + s + ".csv";
FILE *fp = fopen(filename, "wb");
if(fp != NULL)
{
CMiniExcel miniexcel;
miniexcel(0,0) = "No";
miniexcel(0,1) ="Name";
miniexcel(0,2) ="Description";
miniexcel(0,3) ="Low";
miniexcel(0,4) ="High";
miniexcel(0,5) ="Reading";
miniexcel(0,6) ="Result";
for (int i = 0; i < m_totalRows; i++)
{
m = i + 1;
miniexcel(m,0)= GetListCtrl().GetItemText(i, 2);
miniexcel(m,1) =GetListCtrl().GetItemText(i, 3);
miniexcel(m,2) = GetListCtrl().GetItemText(i, 4);
miniexcel(m,3)= GetListCtrl().GetItemText(i, 5);
miniexcel(m,4) = GetListCtrl().GetItemText(i, 6);
miniexcel(m,5) = GetListCtrl().GetItemText(i, 7);
miniexcel(m,6) = GetListCtrl().GetItemText(i, 8);
}
miniexcel.Write(fp);
}
fclose(fp);
}
waiting for your valubale reply..
with regards,
mk..
|
|
|
|

|
Hi,
Thank for your library !
How write a formulate with your library ?
For example : "=B1+B2"
Thank !
|
|
|
|

|
Hi,
first of all i like congrtas to you for your great works done here..
using this one how to make .csv file instaed of excel file???
i want to write in to .csv file instaed if excel file??
how to i do??
waiting for your valable reply...
with regards,
Mk..
-- modified at 2:41 Thursday 26th April, 2007
|
|
|
|

|
Sorry.. not.cav file...
.csv file..
sorry for spcelling mistake..
how to make it .csv file??
with regards,
Mk..
|
|
|
|

|
Could you please suggest me how to store a picture into xls file format?
suvendu
|
|
|
|

|
I have tried the given example but there are 3 error in strdup();
Also this function is not defined anywhere in the given file.
Please give the solution for this function error.
I put command at this 3 error place. but runtime memory exception rised.
|
|
|
|

|
i have try to implement strdup() function like this
somewhere in vector implementation area have problem.
Still problem.
static char *strdup(const char *s)
{
int len = strlen(s) + 1;
r = (char*)malloc(len);
memcpy(r,s,len);
return r;
}
give a solution.
|
|
|
|

|
I want to send for you very big respect! Your are very good programmer though I have some errors while embedding your code in MFC project(I had C1010 error...) but any way I'm using your code with big glad!
|
|
|
|

|
Hi,
Is it possible to merge cells from your files?
VD
Thanks and Rgds,
VamsiDhar.MBC
SoftwareEngineer.
|
|
|
|

|
Actually i am facing a problem when i run the code in VC++ 6.0,its telling Winmain 16.Can u help me in this?
|
|
|
|

|
It is in Project-> Settings->C/C++->Category->Precompiled headers->not using precompiled headers.
with best regards
|
|
|
|

|
Hi
Chage your project properties to "console mode" not win32, thats all....
good luck
|
|
|
|

|
Hi.
Thanks for support. Can u plz feedback to me that how i can run this code under visual C++6?
Bye.
|
|
|
|

|
There are likely a few issues that can arise with VC6 (did not test it, but this would be my best guess):
Precompiled header errors, in which case you either add a "#include " in every ".cpp" file or you disable precompiled headers for the mini-excel files.
WinMain definitions, in which case your project file is likely not configured to use "main(int, char **)" as the main function, so you will have to rename it.
I hope this helps in some way,
Andrei
|
|
|
|

|
if still get error
go to --Project-> Settings->C/C++->Category->Precompiled headers->not using precompiled headers.
with best regards
|
|
|
|

|
Hello:
1) Is it has Process "merged cell"( see follow ) Record in Excel 2.1 Like this: A B C D ... ---------------------------------------- 1 | merged cell | | | ... ---------------------------------------- 2 | | | | | ... ---------------------------------------- 3 . . . . ... . . . . . ... . . . . . ... . . . . . ... 2) What is mean the "Cell is hidden" bit in "rgbAttr" field ? Is it related to other Record or Bit of other Record? Please help me!
|
|
|
|

|
Hi,
Great class.
I noticed that the length of string values is limited to 256 characters.
I have tried extending this value however I cannot get it to work.
Could anybody help me on this any help would be greatly appreciated.
Regards,
Peter Hendrix.
|
|
|
|

|
In the BIFF format that this version of Excel uses, the string length is held in 1 byte, so you cannot really have strings longer than 256 characters (or at least I am not sure how you could manage to do that).
|
|
|
|

|
hi,
i tried to compile you code in (Microsoft development environment 2003 version 7.1.3008)
but it is giving me memory exception.
it is really helpfull.
i need to create the excel file for report generation.
will be thankful to you if you give some more details.
thanks in advance
mawani311@rediffmail.com
|
|
|
|

|
Hi
I just tried this source, an error of memory came up, i fixed it changing the name of the file, ie, doesnt exist the "temp" directory of "c:\\temp\\a.xls", i changed to #define SAVEPATH "c:\\a.xls", and it works perfectly.... check the output file with your excel.... great code.....
|
|
|
|

|
How can i change a particular cell into bold/underline/italic
thanx in advance
- KK -
|
|
|
|

|
First off - great article.
Second - How do I change a cell's number format from general to 0.00 for example, or 0.000000.
Thanks
|
|
|
|

|
Is it possible to extend the code to allow a chart to be created within the excel file.
|
|
|
|

|
Hi.
How can i change colour text and background?
And one more - how can i underline text and "do italic" (sorry for my english)?
Daro
|
|
|
|

|
I have written an Visual C++ Program which creats an Exelfile like this Example. The Program runs under Windows without Office-installation but with "Excel Viewer 2003", to see the result.
It runs perfect.
Now i want to know whether it's possible to set an Autofilter in every Column and how does it function.
Does anybody know?
Olli
|
|
|
|

|
// using MFC CWorksheet sheet.
sheet.put_EnableAutoFilter(TRUE);
CRange range = sheet.get_Range(COleVariant("G12"), COleVariant("G12"));
COleVariant covOptional1((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
range.AutoFilter(covOptional1,covOptional1,0,covOptional1,covOptional1);
// But some where I am doing it wrong and AutoFilter if failing.
vikas chablani
|
|
|
|

|
I'm implementing a Program in VisualC++ which creating an excelfile like this example. The Program run without Office installation on Windows.
The build excel-file can be shown in "Excel Viewer 2003".
Till now, everything runs perfect.
Now i want to know whether it is possible to set an Autofilter in every Column and how does it function.
Anybody know?
Olli
|
|
|
|

|
Hi There.
I am having the same problem now. Did you manage to get the answer to this problem?
w
|
|
|
|

|
this code is very useful for my data-report project, thanks !
one more question or hope:
I like to add a few lines to summarize the report before cell-columns,
and the lines are not restrained in the first column, such as:
[summary lines]
Order Report
number of orders: 34
report period: 4/13/2005 - 5/12/2005
[cells start here]
order_id order_time order_item
1 4/16/05 09:00 xxx
2 4/30/05 14:00 xxx
Hope you help me on this !!
Thanks !!
|
|
|
|

|
trying to append the rows to an existing .xls file,
I changed fopen(SAVEPATH,"wb") to fopen(SAVEPATH, "a+b")
in the main.cpp of the demo-code.
After execution, I opend the .xls file and see the only one
new line and in the line only "item1:","item2:","sum=" are recognized.
Appreciate your time and help!
|
|
|
|

|
The excel file format is not like a normal text file or incremental binary file. This means that you cannot open it in "append" mode since the information has a specific order. Appending to a file would involve reding the existing data, changing it and then re-saving everything. Unfortunately this excel class does not support reading ... you are pretty much stuck with re-creating the file each time.
|
|
|
|

|
Thanks for the explination of the Excel file structure as well as the examples they were of great benefit . A note to anyone running .Net 2003, please do not compile with pre-compiled headers or you will have build errors.
PerpetuaFX Software Design
|
|
|
|

|
Hi there,
First of all thanks for those classes, helped me a lot.
What I need is code for merging two or more cells together.
Is there a way to do that? and How?
Thank you very much in advance.
Ugur
|
|
|
|
|

|
Can anybody guide me on the following:-
1. How to merge cells, say (x,y) and (x+1,y) need to be merged.
2. I've generated daa in a tabular form. How do we make a boundary for the complete table, which diagonally varies from, lets say, (x1,y1) to (x2, y2)
Thanks in advance.
-Piyush
|
|
|
|

|
Hi, love the code, very easy to use and extend...
however, I found a bug with your code - setFontNum and getFontNum should read as follows:
void excelValueAttributes::setFontNum (int v)
{
m_nAttr2 &= ~0xC0; /* clear previous value */
m_nAttr2 |= (v & 0x03) << 6; /* set the new value value */
}
int excelValueAttributes::getFontNum ()
{
return (m_nAttr2 >> 6) & 0x03;
}
Took a little while to track this one down, couldn't understand why my bold text wasn't showing up. Note the different bit shift and mask (the font number goes in bits 6-7 not 5-7).
|
|
|
|

|
Hi, I don't know why I still couldn't get bold text after using your bug-free setFontNum. is v=1 for bold text ?
Thanking for your advice...
|
|
|
|

|
Not quite - first you need to upgrade the code so that it will write FONT records to the xls file.
e.g. in my version of the class, I would write
...
ExcelFile xl;
xl.AddFont("Arial",10); // Font 0, the default font
xl.AddFont("Arial",10,FONT_BOLD); //Font 1, bold font
xl(0,0) = "Normal Text";
xl(0,1) = "Bold Text";
xl(0,1).SetFontNum(1);
...
|
|
|
|

|
Can you please post the code for AddFont()
Thanks
Hans W
|
|
|
|

|
Another buddy earlier asks for the code of AddFont(). May I have it, too? This class is really useful for report data to Excel.
Lai
|
|
|
|

|
Hi..
Do u know How to change Width of Col.
Nice Code..
Thanks
---Sumit Kapoor---
|
|
|
|

|
Yes, you need to write a COLUMNWIDTH record before you write out the records for the strings/numbers.
The openoffice.org / wotsit specs should have all the info you need, I've been working off the openoffice PDF spec.
from memory the structure goes
[standard biff header][start col][end col][width]
|
|
|
|

|
e.g.
//ExcelColumnWidth
ExcelColumnWidth::ExcelColumnWidth(int colno, int width)
{
nColStart = colno;
nWidth = width;
}
void ExcelColumnWidth::Write(LittleEndianWriter *pWriter)
{
BIFFRecord::Write(pWriter, OPCODE_COLWIDTH, 4);
pWriter->Write1(nColStart);
pWriter->Write1(nColStart); //and again for the end index
pWriter->Write2(nWidth);
}
note that width / 256 = width of the zero character in default font (roughly)
|
|
|
|

|
But... How to use ExcelColumnWidth?
Please, explain.
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
Classes used to save data in Excel 2.1 Workbook format
| Type | Article |
| Licence | |
| First Posted | 12 Sep 2002 |
| Views | 252,003 |
| Bookmarked | 104 times |
|
|