Re[4]: Что такое Stack overflow ?
От: Orangeaab Россия  
Дата: 30.12.07 10:21
Оценка:
Здравствуйте, alexeiz, Вы писали:

A>Причина в том, что ты даже программу не можешь отформатировать, так чтобы другие ее могли прочитать и понять. Используй таг [ ccode ].


Да, моя вина.

Вот код программы:
using namespace Excel;

_ApplicationPtr pXL;

pXL.CreateInstance(L"Excel.Application");

pXL->Visible[0] = VARIANT_FALSE;

WorkbooksPtr pBooks = pXL->Workbooks;
_WorkbookPtr pOtchet, pTable;

_WorksheetPtr pSheet, pShOtch;
RangePtr aCell, aCell1, aCell2, aCell3, aCell4, aCell5, aCell6; 

double dWconst;
float M[100000], N[100000], MM[100000], NN[100000],a1, a2, a3, a4, a5, a6, cosf;
float U[11] = {750,500,330,220,110,35,20,15,10,6,0.4};

pBooks->Open("A.xls");
pOtchet = pBooks->GetItem(1);

pBooks->Open("B.xls");
pTable = pBooks->GetItem(2);

for(int z=0, row=6;z<11;z++){
if(z<7 || z==10){row++;}

pSheet = pTable->Worksheets->GetItem(5);
pShOtch = pOtchet->Worksheets->GetItem(3);

aCell1 = pSheet->Cells->Item[2, 1];
a1 = aCell1->Value2;
aCell2 = pSheet->Cells->Item[2, 4]; //N
a2 = aCell2->Value2;
aCell3 = pSheet->Cells->Item[2, 7]; //M
a3 = aCell3->Value2;
for(int j=2;a1 != 0;){
if(a1 == U[z]){
aCell4 = pSheet->Cells->Item[j,9]; //K1
int K1 = aCell4->Value2; 
aCell4 = pSheet->Cells->Item[j,11]; //D1
float D1 = aCell4->Value2; 
aCell4 = pSheet->Cells->Item[j,13]; //Sg1 
float Sg1 = aCell4->Value2; 
aCell4 = pSheet->Cells->Item[j,8]; //K3
int K3 = aCell4->Value2; 
aCell4 = pSheet->Cells->Item[j,10]; //D3
float D3 = aCell4->Value2; 
aCell4 = pSheet->Cells->Item[j,12]; //Sg3
float Sg3 = aCell4->Value2;
aCell4 = pSheet->Cells->Item[j,14]; //Wb
float Wb = aCell4->Value2;

for(int i=0; i<a2; i++){
aCell5 = pSheet->Cells->Item[i+2,4]; // Sgi
M[i]= aCell5->Value2;

aCell6 = pSheet->Cells->Item[i+2,3]; // Di
MM[i]= aCell6->Value2;
}

for(int i=0; i<a3; i++){
aCell4 = pSheet->Cells->Item[i+2,5]; //Sgj
N[i]= aCell4->Value2;

aCell4 = pSheet->Cells->Item[i+2,6]; //Dj
NN[i]= aCell4->Value2;
}

aCell4 = pShOtch->Cells->Item[22,row-4];
a4 = aCell4->Value2;
if(a4 == 0){dWconst = 0;}else{dWconst = aCell4->Value2;}
dWconst = dWpogr(a2, M, MM, a3, N, NN, K1, D1, Sg1, K3, D3, Sg3, Wb);
aCell4->Value2 = dWconst;
}
j+=max(int(a2),int(a3));
aCell1 = pSheet->Cells->Item[j, 1];
a1 = aCell1->Value2;
aCell2 = pSheet->Cells->Item[j, 4];
a2 = aCell2->Value2;
aCell3 = pSheet->Cells->Item[j, 7];
a3 = aCell3->Value2;
}
}



pOtchet->SaveAs("Otchet.xls",xlXMLSpreadsheet, vtMissing, vtMissing, false, false, xlNoChange, vtMissing, vtMissing, vtMissing, vtMissing, vtMissing);
pOtchet->Close();
pTable->Close();

pXL->Quit();
Не пинайте бедного ламера =)
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.