Làm cách nào để xuất Excel với nhiều trang tính theo góc?

Phương thức exportDataGrid[] cho phép người dùng xuất nhiều lưới sang một tài liệu Excel. Do đó, các lưới được xuất trong một chuỗi các Lời hứa

Trong bản trình diễn này, chức năng này được sử dụng để xuất hai DataGrid thành các trang tính riêng biệt trong cùng một sổ làm việc. Vị trí bắt đầu của mỗi lưới đã xuất được đặt bằng thuộc tính topLeftCell

Sử dụng phương thức customCell để tùy chỉnh các trang tính đã xuất

Xem thêm Ẩn chi tiết

Bản demo trước Bản demo tiếp theo

Bản trình diễn này có hữu ích không?

 

 

Cảm ơn bạn

Vui lòng chia sẻ những suy nghĩ liên quan đến bản trình diễn tại đây.
Nếu bạn có thắc mắc về kỹ thuật, vui lòng tạo một thẻ hỗ trợ trong Trung tâm hỗ trợ DevExpress.

x

Gửi thông tin phản hồi

Cảm ơn bạn.
Chúng tôi đánh giá cao phản hồi của bạn.

jQuery

góc cạnh

Vue

Phản ứng

góc cạnhJS

ASP. NET lõi

ASP. NET MVC

API phụ trợ

Sao chép vào CodePen

Áp dụng

Cài lại

const DemoApp = angular.module['DemoApp', ['dx']]; DemoApp.controller['DemoController', [$scope] => { const priceCaption = 'Price'; const ratingCaption = 'Rating'; $scope.buttonOptions = { text: 'Export multiple grids', icon: 'xlsxfile', onClick[] { const dataGrid1 = $['#priceDataGrid'].dxDataGrid['instance']; const dataGrid2 = $['#ratingDataGrid'].dxDataGrid['instance']; const workbook = new ExcelJS.Workbook[]; const priceSheet = workbook.addWorksheet[priceCaption]; const ratingSheet = workbook.addWorksheet[ratingCaption]; priceSheet.getRow[2].getCell[2].value = 'Price'; priceSheet.getRow[2].getCell[2].font = { bold: true, size: 16, underline: 'double' }; ratingSheet.getRow[2].getCell[2].value = 'Rating'; ratingSheet.getRow[2].getCell[2].font = { bold: true, size: 16, underline: 'double' }; function setAlternatingRowsBackground[gridCell, excelCell] { if [gridCell.rowType === 'header' || gridCell.rowType === 'data'] { if [excelCell.fullAddress.row % 2 === 0] { excelCell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'D3D3D3' }, bgColor: { argb: 'D3D3D3' }, }; } } } DevExpress.excelExporter.exportDataGrid[{ worksheet: priceSheet, component: dataGrid1, topLeftCell: { row: 4, column: 2 }, customizeCell[options] { setAlternatingRowsBackground[options.gridCell, options.excelCell]; }, }].then[[] => DevExpress.excelExporter.exportDataGrid[{ worksheet: ratingSheet, component: dataGrid2, topLeftCell: { row: 4, column: 2 }, customizeCell[options] { setAlternatingRowsBackground[options.gridCell, options.excelCell]; }, }]].then[[] => { workbook.xlsx.writeBuffer[].then[[buffer] => { saveAs[new Blob[[buffer], { type: 'application/octet-stream' }], 'MultipleGrids.xlsx']; }]; }]; }, }; $scope.tabPanelOptions = { dataSource: [{ title: priceCaption, template[] { return $["

"].dxDataGrid[{ width: '100%', columns: [ { dataField: 'Product_ID', caption: 'ID', width: 50 }, { dataField: 'Product_Name', caption: 'Name' }, { dataField: 'Product_Sale_Price', caption: 'Sale Price', dataType: 'number', format: 'currency', }, { dataField: 'Product_Retail_Price', caption: 'Retail Price', dataType: 'number', format: 'currency', }, ], showBorders: true, rowAlternationEnabled: true, dataSource: { store: { type: 'odata', url: '//js.devexpress.com/Demos/DevAV/odata/Products', key: 'Product_ID', }, select: ['Product_ID', 'Product_Name', 'Product_Sale_Price', 'Product_Retail_Price'], filter: ['Product_ID', '

Chủ Đề