Get the row of the active Excel cell in C++ - c++

I can't understand why it gives an error - an incorrect value. The task is to write a comment in the selected cell by the excel user.I'm trying to get the row and column of the active excel cell - I get an error.Please help me!
`
Variant App, Bks, Bk, Shts, Sht, Cll,Active;
MSExcel = Variant::GetActiveObject("Excel.Application");
MyBook = MSBooks.OlePropertyGet("Item",1);
Shts = MyBook.OlePropertyGet("Worksheets");
Sht=Shts.OlePropertyGet("Item",1); //В какую страницу нам вставить значение
Variant row = Sht.OlePropertyGet("Selection").OlePropertyGet("Row");
Variant col = Sht.OlePropertyGet("ActiveCell").OlePropertyGet("Column");
Cll=Sht.OlePropertyGet("Cells").OlePropertyGet("Item",row,col);
Cll.OleProcedure("AddComment", comment); `
I can't understand why it gives an error - an incorrect value.

Related

Coldfusion output string not defined

When I execute the code below, resources_gathered is a string, but I get the following error ('Rx222y280.....' is the string in the column resources_gathered):
visualize_resources.cfm?subject_id=395229:105 Uncaught ReferenceError: Rx222y208Rx224y208Rx224y210Rx244y231Rx246y231Rx246y233Rx233y244Rx217y243R is not defined
<cfquery name="getField" datasource="exmind" result="result">
select resources_gathered, completed_fields from dbo.sf
where subject_id=#subject_id#
</cfquery>
<cfset record = getField>
resourcesGathered = JSON.stringify(eval(<cfoutput>#record.resources_gathered#</cfoutput>));
//resourcesGathered = (<cfoutput>#record.resources_gathered#</cfoutput>).toString();
alert(resourcesGathered);
I have tried formatting the string differently before it gets inserted into the table, but I get a reference error anytime I have to read it. Below you can see how I insert it into the table (all code below this point happens in another html file):
<cfquery datasource="exmind">
update dbo.sf
set resources_gathered = <cfqueryparam value="#resources_gathered#"
cfsqltype="cf_sql_nvarchar">
where subject_id = #subject_id#
</cfquery>
The table is correct when I do this, so I am unsure what I need to change to be able to use this data in another html file. I am able to insert/select integers (such as completed_fields) which have been converted to strings, but not this more complex string. Below you can see how the string gets created. It is passed to the query html using a cfform.
for (i=0; i<resources.length; i++) { //resources is an array
if (resources[i].visibility == true){
resourcesFormString += "x";
resourcesFormString += resources[i].x.toString(); //x and y are ints
resourcesFormString += "y";
resourcesFormString += resources[i].y.toString();
resourcesFormString += "R";
}
}
document.getElementById("resources_gathered").value = resourcesFormString;

SpreadsheetFormats not working as expected

I am able to populate data from a query into a spreadsheet. However, I am having problems getting "ranged" formatting to work properly. The formatting for specific column (date) and row (header) work fine. But SpreadsheetFormatColumns, ...Rows, ...CellRange is not. I need to set the font and fontsize to the whole dataset.
Here is what I have tried.
<cfscript>
//Current directory path.
theFile = GetDirectoryFromPath(GetCurrentTemplatePath()) & "GridDump.xls";
//Create a new Excel spreadsheet object and add the query data.
theSheet = SpreadsheetNew("Raw Data");
FormatDate.dataformat = "dd-mmm-yy";
//Get Row Count and Row Range
RC = toString(result.recordcount+1);
RR = "1-" & RC;
//Get Column Count
CC = toString(ListLen(GridFieldNames));
//Get Column Letter
CL = chr(CC + 64);
//Get Column Range (Nummerical)
CRN = "1-" & CC;
//Get Column Range (Alphabetical)
CRA = "A-" & CL;
//Set Sheet Format
WholeSheet = StructNew();
WholeSheet.font="Consolas";
WholeSheet.fontsize=12;
//Set header Row Format
HeadRow = StructNew();
HeadRow.bold="true";
//Insert the Header Row
SpreadsheetAddRow(theSheet,GridFieldNames);
//Insert the Data
SpreadsheetAddRows(theSheet,result);
//Format the Data
SpreadsheetFormatCellRange(theSheet,WholeSheet,1,1,RC,CC);
//SpreadsheetFormatRows(theSheet,WholeSheet,RR);
//SpreadsheetFormatColumns(theSheet,WholeSheet,CRN);
SpreadsheetFormatRow(theSheet,HeadRow,1);
//Header Row
SpreadsheetFormatColumn(theSheet,FormatDate,1);//Date Column
SpreadsheetAddFreezePane(theSheet,0,1);//Top Row Only
//SpreadSheetAddAutofilter(theSheet,"A1:J1");
</cfscript>
Here are the results
I'm getting the same result for all three of the "ranged" formatting functions. The format stops part way through the spreadsheet. I expect the whole dataset to accept any of the ranged function formats.
I got the same result with CF 2018,0,04,314546. Could just be a limitation of XLS format.
Switching to XLSX worked fine for me:
theSheet = SpreadsheetNew("Raw Data", true);
YMMV, but what also worked with CF2018 was using SpreadsheetFormatColumns() instead of SpreadsheetFormatCellRange().

Acumatica GI - Inventory Transaction History Screen

I want to create a GI for Inventory Transaction History Screen (IN405000).
Since the table InventoryTranHistEnqResult isn't present in the database...few of the columns of this screen are taken from INTran Table.
I am not able to find following columns: BegQty, QtyIn, QtyOut, EndQty...
I also tried the following query on database to find these columns
SELECT c.name AS ColName, t.name AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%EndQty%'
The DAC for these fields is:
enter image description here
Looking at the information behind the page in the page Graph will give you the answers to your question. Inventory Transaction History Screen (IN405000) uses graph InventoryTranHistEnq. The grid in this page uses DAC InventoryTranHistEnqResult in the following view:
PXSelectJoin<InventoryTranHistEnqResult,
CrossJoin<INTran>,
Where<True, Equal<True>>,
OrderBy<Asc<InventoryTranHistEnqResult.gridLineNbr>>> ResultRecords
The ResultsRecords are built dynamically in the inquiry using the following:
protected virtual IEnumerable resultRecords()
{
int startRow = PXView.StartRow;
int totalRows = 0;
decimal? beginQty = null;
List<object> list = InternalResultRecords.View.Select(PXView.Currents, PXView.Parameters, new object[PXView.SortColumns.Length], PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
PXView.StartRow = 0;
foreach (PXResult<InventoryTranHistEnqResult> item in list)
{
InventoryTranHistEnqResult it = (InventoryTranHistEnqResult)item;
it.BegQty = beginQty = (beginQty ?? it.BegQty);
decimal? QtyIn = it.QtyIn;
decimal? QtyOut = it.QtyOut;
beginQty += (QtyIn ?? 0m) - (QtyOut ?? 0m);
it.EndQty = beginQty;
}
return list;
}
So i guess the short answer is you cannot use the results of this page for a GI as it is built in the page only. You might want to look into adding what you need to this history page via a customization or make your own version of this page/graph/dac if the information you need is that important.

problems with writing rows to a DataSet in Visual Studio 2010 C++

I am new to Visual Studio 2010 and there seen very few C++ examples of anything on MSDN so would appreciate some help.
I have used the DataSet function from the ToolBox window to create a single table with three columns (for brevity I have left out two of them in the example below.
I am getting the following error:
error C3293: 'Item': use 'default' to access the default property (indexer) for class 'System::Data::DataRow'
Here is the code as generated by VS2010 instantiating the table:
this->GraphInput->DataSetName = L"GraphDataIn";
this->GraphInput->Tables->AddRange(gcnew cli::array< System::Data::DataTable^ >(1) {this->RefElectInput});
//RefElectInput
this->RefElectInput->Columns->AddRange(gcnew cli::array< System::Data::DataColumn^ >(3) {this->RefElect0Av, this->RefElect0Max, this->RefElect0Min});
this->RefElectInput->MinimumCapacity = 7;
this->RefElectInput->TableName = L"RefElecInput";
//
// RefElect0Av
//
this->RefElect0Av->ColumnName = L"RefElect0Av";
this->RefElect0Av->DataType = System::Double::typeid;
Here is the code where I try towrite to the row (I have only shown one column):
DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->Item[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];
//the error data is of type doubleoccurs here.
//other column's removed.
RefElectInput->Rows->Add(myRow);
I would be grateful for your assistance.
Thank you Simon
Have you tried:
DataRow^ myRow;
myRow = RefElectInput->NewRow();
myRow->default[L"RefElect0Av"] = peUnPackDataRec->saeRefElec0.adfRefElecAv[i];

Setting Excel Number Format via xlcFormatNumber in an xll

I'm trying to set the number format of a cell but the call to xlcFormatNumber fails leaving the cell number format as "General". I can successfully set the value of the cell using xlSet.
XLOPER xRet;
XLOPER xRef;
//try to set the format of cell A1
xRef.xltype = xltypeSRef;
xRef.val.sref.count = 1;
xRef.val.sref.ref.rwFirst = 0;
xRef.val.sref.ref.rwLast = 0;
xRef.val.sref.ref.colFirst = 0;
xRef.val.sref.ref.colLast = 0;
XLOPER xFormat;
xFormat.xltype = xltypeStr;
xFormat.val.str = "\4#.00"; //I've tried various formats
Excel4( xlcFormatNumber, &xRet, 2, (LPXLOPER)&xRef, (LPXLOPER)&xFormat);
I haven't managed to find any documentation regarding the usage of this command. Any help here would be greatly appreciated.
Thanks to Simon Murphy for the answer:-
Smurf on Spreadsheets
//It is necessary to select the cell to apply the formatting to
Excel4 (xlcSelect, 0, 1, &xRef);
//Then we apply the formatting
Excel4( xlcFormatNumber, 0, 1, &xFormat);