BigQuery支持将表数据导出到CSV。但是,我想将结果导出到xls。有什么方法导出XLS格式吗?
// Import the Google Cloud client libraries
const {BigQuery} = require('@google-cloud/bigquery');
const {Storage} = require('@google-cloud/storage');
const bigquery = new BigQuery();
const storage = new Storage();
async function extractTableToGCS() {
// Exports my_dataset:my_table to gcs://my-bucket/my-file as raw CSV.
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const datasetId = "my_dataset";
// const tableId = "my_table";
// const bucketName = "my-bucket";
// const filename = "file.csv";
// Location must match that of the source table.
const options = {
location: 'US',
};
// Export data from the table into a Google Cloud Storage file
const [job] = await bigquery
.dataset(datasetId)
.table(tableId)
.extract(storage.bucket(bucketName).file(filename), options);
console.log(`Job ${job.id} created.`);
// Check the job's status for errors
const errors = job.status.errors;
if (errors && errors.length > 0) {
throw errors;
}
}发布于 2022-03-21 10:19:36
BigQuery存储您的数据。当您导出它们时,将以CSV、JSON或其他方式导出数据。这是原始数据。
什么是excel格式?它是原始数据,有额外的元数据信息来格式化单元格,有不同的表格,.
BigQuery只知道数据,不知道要添加的元数据。因此,在export-to-CSV-then-import-data-from-CSV-in-Google-Sheet).中没有内置功能可以导出到BigQuery (导出到Google只是BigQuery的一个快捷方式)。您需要格式化您自己的文件,因此对其进行编码。(如果要创建PDF,则相同)
https://stackoverflow.com/questions/71554866
复制相似问题