Changeset 7654 for trunk/www/common/plugin/parse_file.jsp
- Timestamp:
- Mar 15, 2019, 2:35:35 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/www/common/plugin/parse_file.jsp
r7605 r7654 39 39 import="net.sf.basedb.clients.web.Base" 40 40 import="net.sf.basedb.util.Values" 41 import="net.sf.basedb.util.formatter.DateFormatter" 42 import="net.sf.basedb.util.NumberFormatUtil" 43 import="net.sf.basedb.util.excel.XlsxToCsvUtil" 44 import="net.sf.basedb.util.excel.XlsxToCsvUtil.SheetInfo" 41 45 import="net.sf.basedb.util.fuzzy.StringMatcher" 42 46 import="net.sf.basedb.util.fuzzy.StringMatcher.FuzzyMatch" … … 65 69 { 66 70 String path = request.getParameter("path"); 67 String charsetName = Values.getString(request.getParameter("charset"), Config.getCharset()); 71 boolean excelMode = "excel".equals(Values.getString(request.getParameter("filemode"))); 72 String charsetName = Values.getString(request.getParameter("charset"), excelMode ? "UTF-8" : Config.getCharset()); 73 String sheet = Values.getStringOrNull(request.getParameter("sheet")); 68 74 PluginConfigurationRequest pcRequest = sc.getSessionSetting("plugin.configure.request"); 69 75 Plugin plugin = pcRequest.getPlugin(); … … 100 106 } 101 107 102 String dataSplitter = Values.getString OrNull(request.getParameter("dataSplitter"));108 String dataSplitter = Values.getString(request.getParameter("dataSplitter"), excelMode ? "\\t" : null); 103 109 if (dataSplitter != null) 104 110 { … … 163 169 fileInputStream = wex.wrapInputStream(fileInputStream); 164 170 } 171 172 if (excelMode) 173 { 174 // TODO - this should be inside the FlatFileParser 175 String dateFormat = Values.getString(request.getParameter("dateFormat"), "yyyy-MM-dd"); 176 XlsxToCsvUtil util = new XlsxToCsvUtil(); 177 util.setDateFormat(new DateFormatter(dateFormat)); 178 util.setEvaluateFormulas(true); 179 util.readWorkbook(fileInputStream); 180 SheetInfo sheetInfo = util.getSheetAsCsv(sheet); 181 fileInputStream = sheetInfo.parseToCsv(); 182 } 183 165 184 parser.setInputStream(fileInputStream, charsetName); 166 185 lastLine = parser.parseHeaders(); … … 207 226 title="File data" 208 227 > 209 228 <div id="waitWhileParsing" class="absolutefull bg-filled-100" style="display: none;"> 229 <div class="messagecontainer error"> 230 Parsing file. Please wait... 231 </div> 232 </div> 233 <div id="myContent"> 210 234 <% 211 235 if (file == null) 212 236 { 213 237 %> 214 <div class="absolutefull bg-filled- 50">238 <div class="absolutefull bg-filled-100"> 215 239 <div class="messagecontainer error"> 216 240 No file selected. Please select a file to test above. … … 224 248 { 225 249 %> 226 <div class="bg-filled- 50" style="padding: 5px;">250 <div class="bg-filled-100" style="padding: 5px;"> 227 251 <div class="messagecontainer error" style="margin: 0;"> 228 252 <b>Could not parse the file <code><%=HTML.encodeTags(path)%></code></b> … … 384 408 } 385 409 %> 410 </div> 386 411 </t:tab> 387 412
Note: See TracChangeset
for help on using the changeset viewer.