Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
topsun-baoshen-excel
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何远江
topsun-baoshen-excel
Commits
4a5cc487
Commit
4a5cc487
authored
Jan 04, 2024
by
何远江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
标题bug修改
parent
943ebc69
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
8 deletions
+38
-8
excel.ts
src/utils/excel.ts
+38
-8
No files found.
src/utils/excel.ts
View file @
4a5cc487
import
type
{
Recordable
}
from
'@/types/global'
import
{
ElMessage
}
from
'element-plus'
const
luckysheet
=
(
window
as
any
).
luckysheet
export
function
chatatABC
(
n
:
number
)
{
var
orda
=
'a'
.
charCodeAt
(
0
)
...
...
@@ -55,11 +57,18 @@ export function handleRangeTitle(range: any, dataArea: Recordable) {
const
titles
:
Recordable
[]
=
[]
let
isVertical
=
false
if
(
rowLen
-
1
===
endRow
-
beginRow
&&
columnLen
-
1
!==
endColum
-
beginColum
)
{
// 只有一行,只能横向
if
(
rowLen
==
1
)
{
isVertical
=
false
}
else
if
(
rowLen
-
1
===
endRow
-
beginRow
&&
columnLen
-
1
!==
endColum
-
beginColum
)
{
isVertical
=
true
}
console
.
log
(
'isVertical'
,
isVertical
,
rowLen
,
columnLen
,
dataArea
)
/**
* 取最后一个单元格的坐标,值为最后一个单元格,如果当前单元格没有值,继承前一个单元格值
*
* 横向:以列为单位取值,多值取最后有值单元格
*
* 纵向:以行为单位,多值取最后有值单元格
...
...
@@ -74,23 +83,44 @@ export function handleRangeTitle(range: any, dataArea: Recordable) {
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
)
}
catch
{
v
=
title
.
title
}
// 如果有单元格合并,跳过单元格
if
(
cell
?.
mc
)
{
r
+=
isVertical
?
cell
.
mc
.
rs
-
1
:
cell
.
mc
.
cs
-
1
c
+=
isVertical
?
cell
.
mc
.
cs
-
1
:
cell
.
mc
.
rs
-
1
}
title
.
title
=
v
.
replaceAll
(
' '
,
''
)
title
.
colum
=
+
beginColum
+
(
isVertical
?
r
:
c
)
title
.
row
=
+
beginRow
+
(
isVertical
?
c
:
r
)
}
titles
.
push
(
title
)
}
return
titles
}
/**
* 获取当前选取的坐标
* @returns
*/
export
function
getRangePosition
()
{
const
sheet
=
luckysheet
.
getSheet
()
if
(
sheet
.
luckysheet_select_save
.
length
==
1
)
{
const
[
beginRow
,
endRow
]
=
sheet
.
luckysheet_select_save
[
0
].
row
const
[
beginColum
,
endColum
]
=
sheet
.
luckysheet_select_save
[
0
].
column
return
{
endRow
,
beginRow
,
endColum
,
beginColum
}
}
else
{
ElMessage
.
error
(
'请选择一个区域!'
)
return
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment