|
잘은모르지만 데이터를 엑셀파일로 저장하기서 본 홈페이지에 있는 소스들을
이용해서 저장하는 것은 했는데, 파일명을 제가 지정하여 저장시키고 엑셀을 종료시키게
하고 싶은데 아래 소스는 엑셀이 실행되고 데이터가 셀에 삽입된채로 가만이 있습니다.
즉, 엑셀이 실행되지 않는상태에서 변수에 있는데이터를 엑셀파일에 파일명을 제가
임의로 프로그램에서 지정하면서 저장하게 할수 있을것 같은데 방법을 모르겠습니다.
고수님들의 도움바랍니다.
또한 새로운 시트의 추가나 시트의 이름변경, 차트그리기등도 하고 싶은데
어떤자료를 보아야 되나여?
if(xlApp.IsEmpty())
{
xlApp = Variant::CreateObject("Excel.Application");
}
xlApp.OlePropertySet("Visible", true);
Variant xlBooks;
xlBooks = xlApp.OlePropertyGet("Workbooks");
xlBooks.OleProcedure("Add"); //파일을 새로 만들때
Variant xlBook = xlBooks.OlePropertyGet("Item", 1);
Variant xlSheets = xlBook.OlePropertyGet("Worksheets");
Variant xlSheet = xlSheets.OlePropertyGet("Item", 1);
Variant VRange;
VRange = xlSheet.OlePropertyGet("Range", "A1");
VRange.OlePropertySet("Value", "Count");
VRange = xlSheet.OlePropertyGet("Range", "B1");
VRange.OlePropertySet("Value", "T1[min]");
VRange = xlSheet.OlePropertyGet("Range", "C1");
VRange.OlePropertySet("Value", "Temp[K]");
VRange = xlSheet.OlePropertyGet("Range", "D1");
VRange.OlePropertySet("Value", "T2[min]");
VRange = xlSheet.OlePropertyGet("Range", "E1");
VRange.OlePropertySet("Value", "Tref[K]");
VRange = xlSheet.OlePropertyGet("Range", "F1");
VRange.OlePropertySet("Value", "T3[min]");
VRange = xlSheet.OlePropertyGet("Range", "G1");
VRange.OlePropertySet("Value", "P[W]");
VRange = xlSheet.OlePropertyGet("Range", "H1");
VRange.OlePropertySet("Value", "T4[min]");
VRange = xlSheet.OlePropertyGet("Range", "I1");
VRange.OlePropertySet("Value", "I[Arms]");
VRange = xlSheet.OlePropertyGet("Range", "J1");
VRange.OlePropertySet("Value", "T5[min]");
VRange = xlSheet.OlePropertyGet("Range", "K1");
VRange.OlePropertySet("Value", "S[mm]");
VRange = xlSheet.OlePropertyGet("Range", "L1");
VRange.OlePropertySet("Value", "T6[min]");
VRange = xlSheet.OlePropertyGet("Range", "M1");
VRange.OlePropertySet("Value", "Error");
xlSheet = xlApp.OlePropertyGet("ActiveSheet");
for(int Row=0; Row<DataLengthOfMotor; Row++)
{
//Worksheets("Sheet1").Cells(6, 1).Value = 10
xlSheet.OlePropertySet("Cells", Row+2, 1,Row+1);
xlSheet.OlePropertySet("Cells", Row+2, 2,TimeColdTemp[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 3,ColdTemp[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 4,TimeColdTempref[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 5,ColdTempref[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 6,TimeMotorPower[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 7,MotorPower[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 8,TimeMotorCurrent[Row]);
xlSheet.OlePropertySet("Cells", Row+2, 9,MotorCurrent[Row]);
xlSheet.OlePropertySet("Cells", Row+2,10,TimeMotorStroke[Row]);
xlSheet.OlePropertySet("Cells", Row+2,11,MotorStroke[Row]);
xlSheet.OlePropertySet("Cells", Row+2,12,TimeErrorCode[Row]);
xlSheet.OlePropertySet("Cells", Row+2,13,ErrorCode[Row]);
}
|