-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsimple-conversion.js
More file actions
38 lines (31 loc) · 956 Bytes
/
simple-conversion.js
File metadata and controls
38 lines (31 loc) · 956 Bytes
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
/**
* Simple conversion example - XML to Excel
*
* This example shows the simplest way to convert a file.
*/
const { ConversionToolsClient } = require('conversiontools');
// Get API token from environment or use directly
const apiToken = process.env.CONVERSION_TOOLS_API_TOKEN || 'your-api-token-here';
async function main() {
// Initialize client
const client = new ConversionToolsClient({
apiToken,
});
try {
console.log('Converting XML to Excel...');
// Simple one-liner conversion
const outputPath = await client.convert({
type: 'convert.xml_to_excel',
input: './test.xml', // Your input file
output: './result.xlsx', // Output file (optional)
options: {
excel_format: 'xlsx',
},
});
console.log(`✓ Conversion successful! File saved to: ${outputPath}`);
} catch (error) {
console.error('✗ Conversion failed:', error.message);
process.exit(1);
}
}
main();