1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
void Print_Spreadsheet (vector<vector<Cell>>& Spreadsheet, int column, int row)
{
int a, b, wide = 11, high=18, len, num;
double fl;
string rub(13,' ');//Remove contents of entered cell
for( a=1;a<wide;a++)
{
gotoXY(7+(14*a), 1, Spreadsheet[0][a+column].text + " ");
for( b=1;b<high;b++)
{
gotoXY(6, 1+(b*2));
if(Spreadsheet[b+row][0].number < 10)
cout << " ";
cout << Spreadsheet[b+row][0].number;
gotoXY(1+(14*a), 1+(b*2),rub);
if(Spreadsheet[b+row][a+column].number != -1)
{
len=6;// Start. Centers the results
num = Spreadsheet[b+row][a+column].number;
if(num>99)
len-=1;
if(num>999)
len-=1;
if(num>9999)
len-=1;
if(num>99999)
len-=1;// Keeps subtracting the larger
// number gets. Works ok for decimals
gotoXY(1+len+(14*a), 1+(b*2), num);
}
else if(Spreadsheet[b+row][a+column].dubl > -1)
{
len=6;
fl = Spreadsheet[b+row][a+column].dubl;
if(fl > 99.001)
len-=1;
if(fl > 999.001)
len-=1;
if(fl > 9999.001)
len-=1;
if(fl > 99999.001)
len-=1;
gotoXY(1+len+(14*a), 1+(b*2));
cout << fl;
// Doesn't work well with doubles
}
else if(Spreadsheet[b+row][a+column].text != ".")
{
Spreadsheet[b+row][a+column].text.erase( 0, Spreadsheet[b+row][a+column].text.find_first_not_of(' ') );
len = (Spreadsheet[b+row][a+column].text.length())/2;
gotoXY((7-len)+(14*a), 1+(b*2), Spreadsheet[b+row][a+column].text);
}
if(Spreadsheet[b+row][a+column].function > "")
{
Do_Math(Spreadsheet, a+column, b+row);
// Above does the math only. No printing
}
}
}
}
|