You can browse fields of a table with something along those lines :
SysDictTable dictTab = new SysDictTable(tableNum(InventTable));
SysDictField dictField;
Int i;
for (i=1 ; i <= this.fieldCnt(); i++) {
dictField = new SysDictField(dictTab.column2id(i));
//Export the name to excel with dictField.name();
}
Maybe you'll have to work that out for fields that have dimensions.
Part 2:
Would this resolve your problem?
Create a "new" method for you class myClass :
void new(str _exportPath){
exportPath = _exportPath;
// Where "exportPath" is a variable of myClass;
}
now create your class in the "clicked" method like this :
myNewClass = new myClass("C:\\XPFile.xls");
Good luck!
Steeve...
-----Message d'origine-----
De�: Baran Sasmaz [mailto:[EMAIL PROTECTED]
Envoy�: 9 juin 2004 10:29
��: [EMAIL PROTECTED]
Objet�: [development-axapta] Hello Axapta Dev. Members && Que : Export to Excel?
Hi,
I m a new Axapta developer frm Turkey.
I ve some difficulties while exporting data to excel
from code.
Here is my code (class method) :
-------------------------------------------------
void exportToExcel()
{
SysExcelApplication app;
SysExcelWorksheet Worksheet;
SysExcelWorksheets Worksheets;
SysExcelWorkbooks Workbooks;
SysExcelWorkbook Workbook;
SysExcelRange SysExcelRange;
SysExcelCell RCell;
SysExcelCells Cells;
myTable rs;
COMVariant COMVariant1;
int i;
;
#excel
app =
SysExcelApplication::construct();
Workbooks = app.Workbooks();
Workbook = Workbooks.Add();
Worksheets = Workbook.worksheets();
Worksheet = Worksheets.itemFromNum(1);
Worksheet.name("myTable");
Cells = Worksheet.Cells();
i = 1;
// Construct first row of the excel worksheet
(table field names)
RCell = Cells.Item(i, 1);
RCell.Value("GroupId");
RCell = Cells.Item(i, 2);
RCell.Value("Description");
RCell = Cells.Item(i, 3);
RCell.Value("FieldInt");
RCell = Cells.Item(i, 4);
RCell.Value("FieldReal");
RCell = Cells.Item(i, 5);
RCell.Value("FieldDate");
// Export all table data to excel worksheet
while select rs
{
i++;
RCell = Cells.Item(i, 1);
RCell.Value(rs.GroupId);
RCell = Cells.Item(i, 2);
RCell.Value(rs.Description);
RCell = Cells.Item(i, 3);
RCell.Value(rs.FieldInt);
RCell = Cells.Item(i, 4);
RCell.Value(rs.FieldReal);
RCell = Cells.Item(i, 5);
RCell.Value(date2str
(rs.FieldDate,123,2,2,2,2,2));
}
if (Winapi::fileExists("C:\\myExcel.xls"))
Winapi::deleteFile("C:\\myExcel.xls");
Workbook.saveAs("C:\\myExcel.xls");
Workbooks.close();
}
-------------------------------------------------
Firstly, I want to construct first row of the excel
worksheet dynamically by getting the number and the
name of the myTable's fields. How to get them?
The method that i wrote above is a method of
"myClass". I create a new instance of "myClass" in a
button click, then I call the method above. I wish
also to declare a class variable (in the class
declaration) and wish to set this variable the path
"C:\\myExcel.xls" in the button click. After that, i
ll use this variable in the method written above.
Can anybody help me?
Code examples will be more useful.
Thanks in advance.
Baran
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

