IDEMPIERE-4801 Add IMediaView interface and Keikai implementation (#792)

Add preview for CSV on attachment window
This commit is contained in:
Carlos Ruiz 2021-07-24 07:06:53 +02:00 committed by GitHub
parent a4dfd191ec
commit 298dbab9d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -218,6 +218,7 @@ public class MimeType
{ ".csh", "text/x-script.csh"},
// { ".css", "application/x-pointplus"},
{ ".css", "text/css"},
{ ".csv", MediaType.CSV_UTF_8.toString()},
{ ".cvs", "application/vnd.ms-excel"},
{ ".cxx", "text/plain"},

View File

@ -27,6 +27,8 @@ package org.idempiere.keikai.view;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.List;
import org.idempiere.ui.zk.media.IMediaView;
@ -83,7 +85,12 @@ public class CSVMediaView implements IMediaView {
Book book = importer.imports(bais, media.getName());
spreadsheet.setBook(book);
Sheet sheet = book.getSheetAt(0);
ICsvListReader csvListReader = new CsvListReader(media.getReaderData(), CsvPreference.STANDARD_PREFERENCE);
Reader reader;
if (media.isBinary())
reader = new InputStreamReader(new ByteArrayInputStream(media.getByteData()));
else
reader = media.getReaderData();
ICsvListReader csvListReader = new CsvListReader(reader, CsvPreference.STANDARD_PREFERENCE);
List<String> headers = csvListReader.read();
if (headers != null) {
for(int i = 0; i < headers.size(); i++) {