-
September 2nd, 2010, 03:14 AM
#1
How can Write and Display Date and currency in excel?
Hi all,
i m using excel automation to write excel but is write date or any amount with currency symbol its not displayed properly in excel sheet.
please help me how can i display it.
thank in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
-
September 2nd, 2010, 03:23 AM
#2
Re: How can Write and Display Date and currency in excel?
And how are you doing it now?
Victor Nijegorodov
-
September 2nd, 2010, 05:29 AM
#3
Re: How can Write and Display Date and currency in excel?
Code:
CoInitialize(NULL);
{
Excel::_ApplicationPtr XL;
HRESULT hr;
try
{
XL.CreateInstance(L"Excel.Application");
// create workbook & worksheet
// identify range to which array will be assigned
_variant_t var((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
XL->Workbooks->Add(Excel::xlWorksheet);
Excel::_WorksheetPtr pSheet = XL->ActiveSheet;
Excel::RangePtr pRange = pSheet->Cells;
Excel::RangePtr pBeginRange = pRange->Item[1][1];
Excel::RangePtr pEndRange = pRange->Item[1][1];
Excel::RangePtr pTotalRange = pSheet->Range[(Excel::Range*)pBeginRange][(Excel::Range*)pEndRange];
// create some BSTRs
wchar_t wsz1[] = L"C";
wchar_t wsz2[] = L"D";
BSTR bstr1;
bstr1 = SysAllocString(wsz1);
BSTR bstr2;
bstr2 = SysAllocString(wsz2);
// create safearray
SAFEARRAYBOUND rgsabound[2] = { 0 };
rgsabound[0].cElements = 1; // num rows
rgsabound[0].lLbound = 0; // lower bound
rgsabound[1].cElements = 1; // num cols
rgsabound[1].lLbound = 0; // lower bound
VARIANT arr;
arr.vt = VT_ARRAY | VT_BSTR;
arr.parray = SafeArrayCreate(VT_BSTR,2,rgsabound);
// identify index we want to change
long index[2];
// modify first element <0,0>
index[0] = 0;
index[1] = 0;
hr = SafeArrayPutElement(arr.parray,index,bstr1);
// assign safearray to range
pTotalRange->PutValue2(&arr);
// cleanup
VariantClear(&arr);
SysFreeString(bstr1);
SysFreeString(bstr2);
XL->Visible = true;
}
catch(_com_error &error)
{
cout << "COM error " << endl;
}
}
CoUninitialize();
This happens when i run application on Office 2010 Beta version.while i run application on office 2007 its working fine.
and also tell me how to write date or any amount with currency symbol in excel because by this metod its not displayed properly in excel sheet.
thanks.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
-
September 2nd, 2010, 05:34 AM
#4
Re: How can Write and Display Date and currency in excel?
This happens when i run application on Office 2010 Beta version.while i run application on office 2007 its working fine.[/QUOTE]Then check out how, where and why "Office 2010 Beta" differs from "office 2007".
Or, at least, wait for the finale release of Office 2010.
Victor Nijegorodov
-
September 2nd, 2010, 06:50 AM
#5
Re: How can Write and Display Date and currency in excel?
sir there is no other option for this?
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
-
September 2nd, 2010, 06:53 AM
#6
Re: How can Write and Display Date and currency in excel?
Originally Posted by vjshankwar
sir there is no other option for this?
"other option for" what? For not read the documentation?
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|