Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
a59b4cd6
Commit
a59b4cd6
authored
Nov 18, 2016
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function _getTableFromText
parent
0667b4c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
112 additions
and
1 deletion
+112
-1
cell/model/clipboard.js
cell/model/clipboard.js
+112
-1
No files found.
cell/model/clipboard.js
View file @
a59b4cd6
...
...
@@ -2237,6 +2237,7 @@
return
;
}
//var aResult = this._getTableFromText(text);
var
aResult
=
new
excelPasteContent
();
aResult
=
aResult
.
getDefaultPasteContent
(
worksheet
,
this
.
activeRange
.
r1
,
this
.
activeRange
.
c1
,
text
);
...
...
@@ -2444,7 +2445,117 @@
}
return
res
;
}
},
_getTableFromText
:
function
(
sText
)
{
var
t
=
this
;
var
aResult
=
new
excelPasteContent
();
var
width
=
0
;
var
colCounter
=
0
;
var
rowCounter
=
0
;
var
sCurPar
=
""
;
var
sCurChar
=
""
;
for
(
var
i
=
0
,
length
=
sText
.
length
;
i
<
length
;
i
++
)
{
var
Char
=
sText
.
charAt
(
i
);
var
Code
=
sText
.
charCodeAt
(
i
);
var
Item
=
null
;
if
(
colCounter
>
width
)
{
width
=
colCounter
;
}
if
(
'
\n
'
===
Char
)
{
if
(
""
==
sCurChar
)
{
var
cell
=
aResult
.
getCell
(
rowCounter
,
colCounter
);
cell
.
content
[
0
]
=
{
text
:
""
,
format
:
{}};
colCounter
=
0
;
rowCounter
++
;
//sHtml += "<tr><td style='font-family:Calibri'> </td></tr>";
}
else
{
var
cell
=
aResult
.
getCell
(
rowCounter
,
colCounter
);
cell
.
content
[
0
]
=
{
text
:
sCurChar
,
format
:
{}};
colCounter
=
0
;
rowCounter
++
;
//sHtml += "<tr><td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td></tr>";
sCurChar
=
""
;
}
/*else if(sCurPar != '')
{
var cell = aResult.getCell(rowCounter, colCounter);
cell.content[0] = {text: sCurChar, format: {}};
colCounter = 0;
rowCounter++;
//sCurPar += "<td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td>";
//sHtml += "<tr>" + sCurPar + "</tr>";
sCurChar = "";
sCurPar = "";
}*/
}
else
if
(
13
===
Code
)
{
continue
;
}
else
{
if
(
32
==
Code
||
160
==
Code
)
//160 - nbsp
{
sCurChar
+=
"
"
;
}
else
if
(
9
===
Code
)
//tab
{
var
cell
=
aResult
.
getCell
(
rowCounter
,
colCounter
);
cell
.
content
[
0
]
=
{
text
:
sCurChar
,
format
:
{}};
colCounter
++
;
/*sCurPar += "<td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td>";
if(i == length - 1)
{
sHtml += "<tr>" + sCurPar + "</tr>";
}*/
sCurChar
=
''
;
}
else
{
sCurChar
+=
t
.
_copyPasteCorrectString
(
Char
);
if
(
i
==
length
-
1
)
{
var
cell
=
aResult
.
getCell
(
rowCounter
,
colCounter
);
cell
.
content
[
0
]
=
{
text
:
sCurChar
,
format
:
{}};
//sCurPar += "<td><span style='font-family:Calibri;font-size:11pt;white-space:nowrap'>" + sCurChar + "</span></td>";
//sHtml += "<tr>" + sCurPar + "</tr>";
}
}
}
}
aResult
.
props
.
cellCount
=
width
+
1
;
aResult
.
props
.
rowSpanSpCount
=
0
;
return
aResult
;
},
_copyPasteCorrectString
:
function
(
str
)
{
var
res
=
str
;
res
=
res
.
replace
(
/&/g
,
'
&
'
);
res
=
res
.
replace
(
/</g
,
'
<
'
);
res
=
res
.
replace
(
/>/g
,
'
>
'
);
res
=
res
.
replace
(
/'/g
,
'
'
'
);
res
=
res
.
replace
(
/"/g
,
'
"
'
);
return
res
;
},
};
/** @constructor */
...
...
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