Copying Nattable cells and pasting in excel does not work properly - swt

My nattable looks like the one below.
When I copy the cells and paste in excel the cells look distorted as below.
The line break is not captured properly in the process.
The bit of code referred for copying is the same as that in the Nattable example
Is this a bug and solved in the next versions or am I missing on something.

I would not say that this is a bug in NatTable. Pasting a line break into Excel inside a cell is not that simple. You can search for this topic and see the real issue. When you copy content from NatTable, the content includes the line breaks of your cell data. The paste operation in Excel takes those line breaks and interpretes them as new row and not new line inside a cell.
You can of course implement and register a custom CopyDataCommandHandler that performs special operations to replace a line breaks in NatTable content with something that Excel handles as line breaks inside a cell.

The solution as of now is as follows :-
In Excel if the content that is sent to the Clipboard is present in double quotes and the \n is included in the double quotes Excel interprets this as a single cell content and adds the line break in the cell
Alternatively since this is a table while copying content to the clipboard we can convert it to html tags appropriately and convert it to html format which excel reads and converts appropriately.
Refer below image
However while copying between cells from Nattable to Nattable this is taken care of.

Related

Deleting the last paragraph in a table cell in MS Word

In an empty table cell with the cursor inside, I am inserting multiple paragraphs of text (each with different styles) using insertFileFromBase64.
When no newline is present at the bottom of the Base64 DOCX file, the last paragraph will not receive the style assigned to it within the Base64 DOCX file.
However, when a newline is present within the Base64 DOCX file, I cannot get rid of it. Selecting the last paragraph within the cell and performing a delete does not return an error, but the newline remains present.
I guess this is related to the special status of the "cell marker" within Word, but I cannot find a way around this problem.
Does anyone know a solution?
Found workaround myself: when you FIRST set the style of the current paragraph to the style of the very last paragraph that is contained in the Base64 DOCX file, then the problem can be avoided. (Of course, this supposes that you know upfront the style of that very last paragraph -- which is not necessarily always the case.)

Creating a loop in MATLAB to split up a list of sentences by a delimiter

I want to be able to run a loop through my current code. I have a cell array with 423 cells. Each cell is a long string of smaller strings that I am trying to separate by the delimiter (;) and I want it to loop through each cell, split the string according to the delimiter and write the cell to the excel sheet i have created. But it only does the most recent cell rather than aggregating all of the cells.
I have an excel sheet (see screenshot), in column C I have lots of small sentences that are all separated with the delimiter ';'. I want the code to go through each row in excel and split up this big bunch of text so that each sentence between the delimiters has its own cell rather than being all together. I have managed to make the code work for one row, so the code seperates all of the small strings in to its own new row or new cell. But I cannot do this for every single row in excel, the code simply overwrites each one. I want to create a loop and iterate the process. I then want it to write this big list to a new excel sheet. I have tried to now create an iteration loop but it is not working correctly; it writes the strings to excel but it is not capturing all of them for some reason.
Here is the code as plaintext:
clc
clear
close all
T = readtable("********","range", "C1:C424");
C = table2cell(T);
for i=2:423
splitlist = unique(strsplit(C{i:i},';'))
writecell(splitlist','not_list.xlsx')
end
You need to add WriteMode', 'append' as input to writecell.
I have only tested this online, but it appears to work fine.
for i = 1:numel(C)
split_str = unique(strsplit(C{i},';'))
writecell(split_str, 'not_list.xlsx', 'WriteMode','append');
end

Trouble rendering CSV data as an interactive table in GitHub

When viewed, any .csv file committed to a GitHub repository automatically renders as an interactive table, complete with headers and row numbering. By default, the first row is your header row. The tables were supposed to look nice as below:
However, there's an error happening in my tabular data, and despite indicating the error, I can't fix it:
I'm using a .csv file with a semicolon separator. Does anyone have an idea of what's happening?
According to the docs, Github can only do its lay-out thing with .csv (comma-separated) and .tsv (tab-separated) files.
Using a semicolon as a separator isn't supported, at least not officially, and a spurious comma in a semicolon-separated file could well throw the algorithm off.
You could try replacing all semicolons with tabs and see how you fare.
If that doesn't work, try using commas as separators and enclose all text table cell data with quotes, like:
"Liver fibrosis, sclerosis, and cirrhosis","c370800","102922","Cystic fibrosis related cirrhosis","Diagnosis of liver fibrosis, sclerosis, and cirrhosis"
Note: no spaces after the commas. Also, if you have quotes in the text fields, you will have to escape those to "" (two quotes), or the algorithm will get confused.
You may get away with using quotes only for the offending text data, but that could well be more difficult to generate than just putting the quotes around all fields.

I am trying to read the time and message value field data as shown below and write it to an excel

Sample data and required excel image:
Also, Read Time section as shown in file, and populate excel file with the data in a column with the header name Time as shown above. Likewise, read the message value as shown in the .asc file and populate in excel file by converting the numbers from hexadecimal to decimal in columns named Data1, Data2, Data3,…
If your '.asc' file consists of tab delimited ASCII text then Excel will allow you to import it into an Excel worksheet.
The following explainer comes from Microsoft's Office support site:
There are two ways to import data from a text file by using Microsoft
Excel: You can open the text file in Excel, or you can import the text
file as an external data range. To export data from Excel to a text
file, use the Save As command.
There are two commonly used text file formats:
Delimited text files (.txt), in which the TAB character (ASCII
character code 009) typically separates each field of text.
Comma separated values text files (.csv), in which the comma character
(,) typically separates each field of text.
You can change the separator character that is used in both delimited
and .csv text files. This may be necessary to make sure that the
import or export operation works the way that you want it to.
If neither of those methods work for you and your '.asc' was generated by MATLAB then you may be able to use MATLAB to export directly to an Excel worksheet. MATLAB has a function xlswrite that you can use to write directly to a Microsoft Excel spreadsheet.
Another option, if you're comfortable writing some VBA code in Excel, is to use the textscan function to parse your '.asc' file.

Way to preserve formatting for lists when copy / pasting from table cell?

My Word interop application needs to get content out of a cell of a table in a word document. The problem is, that the formatting for some items seems broken. For example the last item of a list does not have the list style applyied. Headings are only normal text etc.
The same happens if you create a table, create a list in the table and try to copy / paste the list to somewhere else.
Has anyone else had this problem and maybe found a solution? Is there any way to trick word into giving the correct formatting?
Thanks in advance
Example code
Range range = cell.range;
range.MoveEnd(WdUnits.wdCharacter, -1);
...
range.FormattedText.copy()
The range includes the end-of-cell marker which should not be exported. I just noticed, when not altering the range, list are correctly formatted but the whole cell is exported as a table, which is bad because i want to import the content into another document (where this would nest tables infinitly)
Word2010 v14.06.6112.5000