fix: excel不显示数字0

This commit is contained in:
liyulin 2023-03-07 15:39:37 +08:00
parent f6d205a9d4
commit 0e59e49167
4 changed files with 9 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vue-office/examples/dist/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue</title>
<script type="module" crossorigin src="/vue-office/examples/dist/assets/index-e6b861ed.js"></script>
<script type="module" crossorigin src="/vue-office/examples/dist/assets/index-74060e95.js"></script>
<link rel="stylesheet" href="/vue-office/examples/dist/assets/index-171e346f.css">
</head>
<body>

View File

@ -1,6 +1,6 @@
{
"name": "@vue-office/excel",
"version": "0.2.4",
"version": "0.2.5",
"description": "",
"main": "lib/index.js",
"files": [

View File

@ -56,6 +56,9 @@ function transferColumns(excelSheet, spreadSheet, options){
}
function getCellText(cell){
if(typeof cell.value === 'number'){
return cell.value + ''
}
let cellText = ''
if(cell.value && cell.value.result) {
// Excel 单元格有公式
@ -66,8 +69,7 @@ function getCellText(cell){
// 多行文本做累加
cellText += cell.value.richText[text].text
}
}
else {
} else {
// Excel 单元格无公式
cellText = cell.value
}
@ -182,9 +184,9 @@ function getStyle(cell){
export function transferExcelToSpreadSheet(workbook, options){
let workbookData = []
console.log(workbook, 'workbook')
//console.log(workbook, 'workbook')
workbook.eachSheet((sheet) => {
console.log(sheet,'sheet')
//console.log(sheet,'sheet')
// 构造x-data-spreadsheet 的 sheet 数据源结构
let sheetData = { name: sheet.name,styles : [], rows: {},cols:{}, merges:[],media:[] }
// 收集合并单元格信息