Commit 07d14cda authored by 何远江's avatar 何远江

修改设置标题逻辑,添加附加信息设置

parent 0aa99b16
......@@ -80,5 +80,7 @@ export const authorityConfig = {
export const areaMarksColor = {
'data': '#65d0ea',
'head': '#34718d',
'default': '#ffffff'
'default': '#ffffff',
'attch': '#e6ccb2',
'attch_head': '#b08968'
}
\ No newline at end of file
import type { Recordable } from '@/types/global'
export function chatatABC(n: number) {
var orda = 'a'.charCodeAt(0)
......@@ -21,17 +23,74 @@ export function getRangetxt(row0: number, row1: number, column0: number, column1
// let column0 = range["column"][0], column1 = range["column"][1];
if (row0 == null && row1 == null) {
return chatatABC(column0) + ":" + chatatABC(column1);
return chatatABC(column0) + ':' + chatatABC(column1)
} else if (column0 == null && column1 == null) {
return row0 + 1 + ':' + (row1 + 1)
} else {
if (column0 == column1 && row0 == row1) {
return chatatABC(column0) + (row0 + 1)
} else {
return chatatABC(column0) + (row0 + 1) + ':' + chatatABC(column1) + (row1 + 1)
}
else if (column0 == null && column1 == null) {
return (row0 + 1) + ":" + (row1 + 1);
}
else {
if (column0 == column1 && row0 == row1) {
return chatatABC(column0) + (row0 + 1);
}
export function getRangeState(range: any) {
let rowLen = range.length
let columnLen = range[0].length
let isOneRow = !(rowLen > 1)
let isOneColumn = !(columnLen > 1)
return {
rowLen,
columnLen,
isOneRow,
isOneColumn
}
else {
return chatatABC(column0) + (row0 + 1) + ":" + chatatABC(column1) + (row1 + 1);
}
export function handleRangeTitle(range: any, dataArea: Recordable) {
const { isOneColumn, isOneRow, rowLen, columnLen } = getRangeState(range)
const { beginColum, beginRow, endRow, endColum, sheetNum } = dataArea
const titles: Recordable[] = []
let isVertical = false
if (rowLen - 1 === endRow - beginRow && columnLen - 1 !== endColum - beginColum) {
isVertical = true
}
/**
* 横向:以列为单位取值,多值取最后有值单元格
*
* 纵向:以行为单位,多值取最后有值单元格
*/
for (let c = 0; c < (isVertical ? rowLen : columnLen); c++) {
const title = {
title: '',
sheet: sheetNum,
row: 0,
colum: 0
}
for (let r = 0; r < (isVertical ? columnLen : rowLen); r++) {
const cell = isVertical ? range[c][r] : range[r][c]
let v = ''
// 如果获取值报错,那么断定单元格值为空,继续执行
try {
v = cell.v || cell?.ct?.s.map((itm) => itm.v).join('')
} catch {}
if (v != '') {
title.title = v.replaceAll(' ', '')
title.colum = +beginColum + (isVertical ? r : c)
title.row = +beginRow + (isVertical ? c : r)
}
// 如果有单元格合并,跳过单元格
if (cell?.mc) {
r += isVertical ? cell.mc.rs - 1 : cell.mc.cs - 1
c += isVertical ? cell.mc.cs - 1 : cell.mc.rs - 1
}
}
titles.push(title)
}
return titles
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment