Comments (2)
I've ran into the same issue and the root cause is that Threads
is a valid column with a valid width on its own. That width is stored by the CWC for column 3, because Threads
is actually column 3, spanning column 2. All other rows of column 3 are smaller than Threads
, hence all rows in that column get the length of Threads
.
Spanning etc. seems to be applied later, because instead of handling Threads
as a column on its own, its width in theory is the width of all columns it spans, 2 and 3 in your example. As long as Threads
fits into the space of those two columns, which is the case here, column 3 could be stored with its own width being smaller than Threads
.
At least for cases in which column width is known to be constant, this problem can be worked around by simply setting a maximum width on the calculator:
cwc.add(0, 0).add(0, 0).add(0, 0).add(0, 0).add(0, 26).add(0, 26);
┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Übersicht empfangener Messgeräte. │
╞═════════════════════════════════╤═════════════════════╤═══════════════════╤═══════════════════╤══════════════════════════╤══════════════════════════╡
│ Ableseunternehmen (Benutzer-ID) │ Liegenschaftsnummer │ Datensammler │ Anzahl Messgeräte │ Beginn des Zeitraums │ Ende des Zeitraums │
╞═════════════════════════════════╪═════════════════════╪═══════════════════╪═══════════════════╪══════════════════════════╪══════════════════════════╡
│ 1 │ Real estate mööp 01 │ 00-00-00-00-00-01 │ 1 │ 1970-01-01T00:00:00.000Z │ 1970-02-01T00:00:00.000Z │
vs.
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ Übersicht empfangener Messgeräte. │
╞═════════════════════════════════╤═════════════════════╤═══════════════════╤═══════════════════╤══════════════════════════╤═════════════════════════════════╡
│ Ableseunternehmen (Benutzer-ID) │ Liegenschaftsnummer │ Datensammler │ Anzahl Messgeräte │ Beginn des Zeitraums │ Ende des Zeitraums │
╞═════════════════════════════════╪═════════════════════╪═══════════════════╪═══════════════════╪══════════════════════════╪═════════════════════════════════╡
│ 1 │ Real estate mööp 01 │ 00-00-00-00-00-01 │ 1 │ 1970-01-01T00:00:00.000Z │ 1970-02-01T00:00:00.000Z │
Not sure if there's a good alternative implementation possible in the CWC: One could collect all(!) widths of individual columns instead of only the maximum ones, including the width of spanned columns simply being 0
. Afterwards one could search the result of all columns for the maximum width of all columns and store those in some map of column index to width. Then one could iterate all widths of all rows again and look for spanning columns and calculate their true width using the formerly stored individual maximum columns width. And that's where things get tricky in my opinion: Individual rows might contain multiple spanning columns. All rows might contain spanning columns only at different positions etc.
from asciitable.
I'm attaching a PoC of a different CWC following the line-length approach of CWC_LongestLine as well, but taking the width of spanned columns into account. This works for the above table in my case without setting a maximum width manually, which makes things more flexible for changing content. Maybe someone is interested to review and optionally add it to the project. Didn't provide a PR because I'm not sure about names, if it's worth it etc.
VwrDvResultsCwc.java.txt
VwrDvResultsCwcStringifier.java.txt
from asciitable.
Related Issues (20)
- Empty text in cells cause an exception (when using CWC_LongestLine)
- Cannot set Unix linefeed as separator
- Number alignment
- Support AutoWidth HOT 5
- Fails with 'width must allow for borders'
- Table rendered with question marks instead '-' symbols? HOT 1
- Why is the project so awesome? i love it!
- Thread locks rendering centered content
- Java 11 support HOT 1
- NoClassDefFoundError on Android HOT 1
- Not getting expected output HOT 1
- AsciiTable does not respect newlines as elements HOT 1
- About Java 7 Support HOT 1
- addRow - empty/null strategy
- Markdown table style
- render text in chinese
- Support for colored text content HOT 1
- IndexOutOfBoundsException HOT 2
- Is this project still active? HOT 1
- Output Chinese, its formatting will be messy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciitable.