Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cassiopée
nghyd
Commits
db0304f8
Commit
db0304f8
authored
5 years ago
by
mathias.chouet
Browse files
Options
Downloads
Patches
Plain Diff
Fix
#360
- remove "help" from cells in exported spreadsheets
parent
7bf9e415
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/app.component.ts
+29
-1
29 additions, 1 deletion
src/app/app.component.ts
src/app/components/fixedvar-results/fixed-results.component.ts
+1
-1
1 addition, 1 deletion
...pp/components/fixedvar-results/fixed-results.component.ts
with
30 additions
and
2 deletions
src/app/app.component.ts
+
29
−
1
View file @
db0304f8
...
...
@@ -158,8 +158,36 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
});
// defaults to image/png
}
public
static
exportAsSpreadsheet
(
table
:
ElementRef
)
{
/**
* Exports a results data table to XLSX format, and removes "help" mentions
* from the parameters names columns if needed
* @param table results data table
* @param namesInFirstCol if true, will look for parameters names in 1st column
* (for fixed results), else in 1st row (variable results, by default)
*/
public
static
exportAsSpreadsheet
(
table
:
ElementRef
,
namesInFirstCol
:
boolean
=
false
)
{
const
ws
:
XLSX
.
WorkSheet
=
XLSX
.
utils
.
table_to_sheet
(
table
);
let
regExCellKey
;
if
(
namesInFirstCol
)
{
regExCellKey
=
new
RegExp
(
"
^A
\\
d$
"
);
}
else
{
regExCellKey
=
new
RegExp
(
"
^
\\
w1$
"
);
}
// browse all cells
for
(
const
key
in
ws
)
{
// look for 1st row or 1st col
if
(
regExCellKey
.
test
(
key
)
===
true
)
{
const
regExCellName
=
new
RegExp
(
"
help$
"
);
const
v
:
string
=
ws
[
key
].
v
;
// remove "help" from cell name's ending
if
(
regExCellName
.
test
(
v
)
===
true
)
{
const
newV
=
v
.
substr
(
0
,
v
.
length
-
4
);
ws
[
key
].
v
=
newV
;
}
}
}
const
wb
:
XLSX
.
WorkBook
=
XLSX
.
utils
.
book_new
();
XLSX
.
utils
.
book_append_sheet
(
wb
,
ws
,
"
default
"
);
const
wopts
:
any
=
{
bookType
:
"
xlsx
"
,
bookSST
:
false
,
type
:
"
array
"
};
...
...
This diff is collapsed.
Click to expand it.
src/app/components/fixedvar-results/fixed-results.component.ts
+
1
−
1
View file @
db0304f8
...
...
@@ -272,6 +272,6 @@ export class FixedResultsComponent extends ResultsComponent {
}
public
exportAsSpreadsheet
()
{
AppComponent
.
exportAsSpreadsheet
(
this
.
table
.
nativeElement
);
AppComponent
.
exportAsSpreadsheet
(
this
.
table
.
nativeElement
,
true
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment