c++ qt range of excel querySubObject - c++

I try to write Data from Qt into an excel-File. I found this piece of code letting me write my Data into an 5*5 range.
//get a 5x5 range of cells : from A1 to E5
QAxObject *range = sheet1->querySubObject( "Range(const QString&, const QString&)", QString("A1"), QString("f5"));
QVariant vTable(table);
range->dynamicCall("SetValue(const QVariant&)", vTable);
My data is much bigger than 5 colums and 5 rows and varies in size. Is there a possibility of setting the range with numbers something like:
QAxObject *range = sheet1->querySubObject( "Range(7,123)");
meaning my data should have the size of 7 columns and 123 rows ?
Thanks very much for your answers
Itelly

If your data is 123x7 table then you can initialize your range as
QAxObject *range = sheet1->querySubObject( "Range(A1,G123)");
Assuming that you are storing your values in vTable then you can call :
range->dynamicCall("setValue(const QVariant&)",vTable);
to put your values to spreadsheet.

Related

A cell containing a range of values and making calculations with that range

Is it possible to have a range of values in a cell so that Sheets understands it when calculating something?
Here's an example of the desired output:
A B C
1 Value Share Total sum
2 100.00 90-110% 90-110
Here, Total sum (C2) = A2 * B2 (so 100 * 90-110%), giving a range of 90-110.
However, I don't know how to insert this range of values into a cell without Sheets saying #VALUE!.
you will need to do it like this:
=REGEXREPLACE((A2*REGEXEXTRACT(B2, "\d+")%)&"-"&
A2*REGEXEXTRACT(B2, "-(\d+%)"), "\.$", )
for decimals:
=REGEXREPLACE((A40*REGEXEXTRACT(B40, "\d+.\d+|\d+")%)&"-"&
A40*REGEXEXTRACT(B40, "-(\d+.\d+%)|-(\d+%)"), "\.$", )

Excel Sum values by extracting numbers from single multi-line cell

AL-CHE-P1-1518 --- 270
AL-CHE-P2-1318 --- 280
AL-MAT-P1-1218 --- 280
AL-MAT-P4-0918 --- 40
all these data are inside same cell C2, my aim is to derive a formula to sum
270+280+280+40
in cell D2
tried regextract(c2,"\d(.*)\n") but only the first "270" is extracted, I need help, searched through all forums, couldn't get exact match, it will save me huge time if anyone could give me some hint on how to derive the sum inside same cell string
As far as I know, you can only accomplish this via a UDF:
Function ReturnSum(rng As Range) As Long
Dim arr As Variant
arr = Split(rng.Value, Chr(10) & Chr(10))
For i = 0 To UBound(arr)
ReturnSum = ReturnSum + Trim(Split(arr(i), " --- ")(1))
Next i
End Function
=SUMPRODUCT(ARRAYFORMULA(REGEXEXTRACT(SPLIT(C2,CHAR(10))," \d+")))
In Excel the formula is a bit more complicated and an array formula:
=SUM(IFERROR(--MID(TRIM(MID(SUBSTITUTE(A1,CHAR(10),REPT(" ",99)),(ROW($XFD$1:INDEX(XFD:XFD,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1))-1)*99+1,99)),FIND("---",TRIM(MID(SUBSTITUTE(A1,CHAR(10),REPT(" ",99)),(ROW($XFD$1:INDEX(XFD:XFD,LEN(A1)-LEN(SUBSTITUTE(A1,CHAR(10),""))+1))-1)*99+1,99)))+3,99),0))
Being an array formula it must be confirmed with Ctrl-Shift-Enter instead of Enter when Exiting Edit mode.

Aspose Cell Java - Splitting Cell Horizontally

How do i fit values in those horizontally splitted cells ? I am cloning each row dynamically. The values being populated currently is a merge field as i was using this approach but i couldn't make the report dynamic with it.
Any help would be appreciated.
Well, you cannot input two values in a single cell in MS Excel. I think You may achieve your task by merging/ un-merging some cells and input values into relevant cells accordingly. See the sample code below for your reference, it covers and design some part of your attached table/matrix. Please refer to it and you may write your own code (via Aspose.Cells APIs) to accomplish your task accordingly:
var workbook = new Workbook();
var worksheet = workbook.Worksheets[0];
//Input header value to B1 cell (later we will merge it: B1:C1 --> B1
worksheet.Cells[0, 1].PutValue("header2");
//Input value to B2 cell that would be merged with B3 to become B2.
worksheet.Cells[1, 1].PutValue(1);
//Input value to C2 cell.
worksheet.Cells[1, 2].PutValue(2);
//Input value to C3 cell.
worksheet.Cells[2, 2].PutValue(3);
//Set row heights for 2nd and third rows for the cells accordingly.
worksheet.Cells.SetRowHeight(1, 25);
worksheet.Cells.SetRowHeight(2, 25);
//Merging cells.
//Merge B1:C1 --> B1
worksheet.Cells.Merge(0, 1, 1, 2);
//Merge B2:B3 --> B2
worksheet.Cells.Merge(1, 1, 2, 1);
//Formatting cells and ranges.
//Creating a range that spans over the all data cells of a worksheet
var range = worksheet.Cells.CreateRange("B1", "C3");
//Create a Style object.
Style colstyle = workbook.CreateStyle();
colstyle.Borders[BorderType.LeftBorder].LineStyle = CellBorderType.Thin;
colstyle.Borders[BorderType.RightBorder].LineStyle = CellBorderType.Thin;
colstyle.Borders[BorderType.TopBorder].LineStyle = CellBorderType.Thin;
colstyle.Borders[BorderType.BottomBorder].LineStyle = CellBorderType.Thin;
colstyle.HorizontalAlignment = TextAlignmentType.Center;
StyleFlag flag = new StyleFlag();
flag.Borders = true;
flag.HorizontalAlignment = true;
//Apply the style to the range
range.ApplyStyle(colstyle, flag);
workbook.Save("e:\\test2\\output__mergedcells.xlsx");
See the screen shot of the output Excel file taken in Ms Excel for your reference:
http://prntscr.com/8rbc0i
I am a developer/evangelist at Aspose.

Fixed Length Flat File Table Algorithms in c++

I am doing simple project for table processing using flat files in c++. I have two type of files to access the table data.
1) Index File. ( employee.idx )
2) Table File. ( employee.tbl )
In index file, I have table details in the format of tab delimited . i.e.,
Column-name Column-Type Column-Offset Column-Size
for example, employee.idx
ename string 0 10
eage number 10 2
ecity string 12 10
In Table file, I have the data in the format of Fixed Length.
for example, employee.tbl
first 25Address0001
second 31Address0002
Here I will explain my algorithm what I did in my program.
1) First I have loaded index file data in 2D vector String ( Index Vector ) using fstream.
2) This is my code to load Table File Data into 2D
while (fsMain)
{
if (!getline( fsMain, s )) break;
string s_str;
for(size_t i=0;i<idxTable.size();i++)
{
int fieldSize=stoi(idxTable[i].at(3));
string data (s,stoi(idxTable[i].at(2)),fieldSize);
string tmp=trim_right_inplace(data);
recordVec.push_back( tmp );
}
mainTable.push_back(record);
recordVec.clear();
s="";
}
Ok. Now my question is , " Is there any other better way to load the Fixed length data to memory ? ". I checked this process for 60 tables with 200 Records. It takes nearly 20 Seconds. But I want to load 100 tables with 200 records within one Second. But It takes more time. How can I improve efficiency for this task ?

Data format for MathGL BoxPlot

I want to display a 10x48 dataset (10 sampling points with 48 or more samples each) in a box plot using MathGL. The result should be 10 box plots that summarize the data for each sampling point. The problem I'm having is, I can't figure out what data format the boxplot function from MathGL needs. In the documentation it says that for each entry, 5 values are provided (Minimum, Q1, Q2/Median, Q3, Maximum), yet when I structure the mvlData like such:
mglData(10x5) =
{
Min_1, Q1_1, Q2_1, Q3_1, Max_1,
Min_2, Q1_2, Q2_2, Q3_2, Max_2,
Min_3, Q1_3, Q2_3, Q3_3, Max_3,
...
Min_10, Q1_10, Q2_10, Q3_10, Max_10
}
I do not get the correct outputs. If I'd structure it with data like such:
mglData(10x48) =
{
Data_1_1, Data_1_2, Data_1_3, ... , Data_1_48,
Data_2_1, Data_2_2, Data_2_3, ... , Data_2_48,
Data_3_1, Data_3_2, Data_3_3, ... , Data_3_48,
...
Data_10_1, Data_10_2, Data_10_3, ... , Data_10_48
}
it outputs nice boxplots, but with the wrong values. The example show that the mglData needs to contain Nx7 values, hence in my case 10x7? but I can only see 5 possible values (not 7) or is there more than Minimum, Q1, Q2/Median, Q3, Maximum to a boxplot?
Any help is very appreciated.
Thanks
Max
First variant with transposed dimensions is correct one. You can create an array 10*5 directly (10 points in x-direction) or transpose the current one by function mglData::Transpose().