XLSX

使用时限制文件格式 <input type=“file”> ?

只谈情不闲聊 提交于 2020-01-06 15:32:17
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 当用户单击HTML中 <input type="file"> 元素中的 <input type="file"> 浏览”按钮时,我想限制可以从本机OS文件选择器选择的 <input type="file"> 。 我有一种感觉,这是不可能的,但我想知道是否 有 一个解决方案。 我只想保留HTML和JavaScript; 请不要使用Flash。 #1楼 如前面的答案中所述,我们不能限制用户仅选择给定文件格式的文件。 但是使用html中的file属性上的accept标签确实很方便。 至于验证,我们必须在服务器端进行。 我们也可以在js的客户端执行此操作,但这不是万无一失的解决方案。 我们必须在服务器端进行验证。 对于这些需求,我确实更喜欢struts2 Java Web应用程序开发框架。 借助其内置的文件上传功能,将文件上传到基于struts2的Web应用程序简直是小菜一碟。 只需提及我们希望在应用程序中接受的文件格式,其余所有内容都由框架本身的核心负责。 您可以在struts官方站点上进行检查。 #2楼 严格来说,答案是 否定的 。 开发人员 无法 阻止用户在本机OS文件选择对话框中选择任何类型或扩展名的文件。 但是, <input type = "file"> 的 accept

前端vue使用js-xlsx导出excel的三种方法

坚强是说给别人听的谎言 提交于 2020-01-06 12:28:37
npm install - - save xlsx file - saver 在组件里面引入 import FileSaver from 'file-saver' import XLSX from 'xlsx' 第一种 其中#outTable是在el-table上定义的id exportExcel() { var xlsxParam = { raw: true };//转换成excel时,使用原始的格式 var wb = XLSX.utils.table_to_book(document.querySelector("#outTable"),xlsxParam);//outTable为列表id var wbout = XLSX.write(wb, { bookType: "xlsx", bookSST: true, type: "array" }); try { FileSaver.saveAs( new Blob([wbout], { type: "application/octet-stream;charset=utf-8" }), "sheetjs.xlsx" ); } catch (e) { if (typeof console !== "undefined") console.log(e, wbout); } return wbout;} 第二种 通过数组导出excel

openpyxl reading column width from a .xlsx and writing it to a new .xlsx: width is different in a new file

混江龙づ霸主 提交于 2020-01-06 08:18:36
问题 I am using openpyxl to work with .xlsx files in Python . I have a sample.xlsx file from which I want to get a list of title fields and column width to use in the file generated by my script. At first I create a list with column names and their corresponding widths. So I use: filter_list = {"name": [], "width": []} row_count = sheet.max_row for i in range(row_count): cell = sheet.cell(row, i + 1) if cell.value: filter_list["name"].append(cell.value) filter_list["width"].append(sheet.column

Color cells with specific character values in r to export to xlsx

狂风中的少年 提交于 2020-01-04 04:56:20
问题 I'm trying to accomplish something that shouldn't be that difficult, yet it escapes my tries. So I have an R Data Frame which looks something like this: MeanTemperature(ºC) Longitude Latitude Height FinalConsiderations 5 91ºW 152ºS 548m Slightly Cooler 16 185ºE 53ºN 722m Unchanged 22 16ºW 2ºS 206m Significantly Warmer The dataframe is a result of a filtered analyzed data. The end product is an Excel (xlsx) where the final column is the conclusion of the overall analysis. So, those steps are

Transposing a data frame while preserving class/data type information

怎甘沉沦 提交于 2020-01-03 15:34:23
问题 tl;dr How can I transpose a data frame with column vectors of different classes (one column is character , the next is numeric , yet another is logical etc.) in a way that preserves the class/data type information? Example data: mydata <- data.frame( col0 = c("row1", "row2", "row3"), col1 = c(1, 2, 3), col2 = letters[1:3], col3 = c(TRUE, FALSE, TRUE) ) Here's also a little xlsx file that features examples for both data orientations: https://github.com/rappster/stackoverflow/blob/master/excel

How can I delete a Column of XLSX file with EPPlus in web app

无人久伴 提交于 2020-01-03 03:21:06
问题 How can I delete a column of a .XLSX file with EPPlus in a web application? I use EPplus for generating Excel reports and a stored procedure to get the data from database. The problem is that I want to remove one of the columns of information in the report file by EPplus (stored procedure should not be changed.) I would remove the additional column in and also want to change the page layout direction to (right to left), but it does not work '----/// Click Report Button ///---- Protected Sub

How to find out what makes poi corrupt a xlsx / xlsm file

有些话、适合烂在心里 提交于 2020-01-03 02:48:25
问题 I have the issue that Apache POI "corrupted" a xlsm / xlsx file by just reading and writing it (e.g. with the following code) public class Snippet { public static void main(String[] args) throws Exception { String str1 = "c:/tmp/spreadsheet.xlsm"; String str2 = "c:/tmp/spreadsheet_poi.xlsm"; // open file XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(new File(str1))); // save file FileOutputStream out = new FileOutputStream(str2); wb.write(out); wb.close(); out.close(); } } Once you

Error reading timestamps using “xlsx” package

こ雲淡風輕ζ 提交于 2020-01-02 14:33:51
问题 Data in Excel file looks like TIMESTAMP TYPE BID BIDSIZ 2015-01-04 09:00:00 BID 365 10 2015-04-01 09:00:05 BID 367.8 55 2015-04-01 09:00:33 BID 365 10 2015-04-01 09:00:36 BID 367.8 55 When I run the following code: require(xlsx) f1<-read.xlsx2("Canara_Data.xlsx", sheetName = "BID") f1$TIMESTAMP<-as.POSIXct(f1$TIMESTAMP, format="%Y-%M-%D %H:%M:S") viewing it causes TIMESTAMP to look like View(`f1`) TIMESTAMP X. BID BIDSIZ 42008.375 BID 365 10 42095.37505787037 BID 367.8 55 42095.37538194445

“read_excel” in a Shiny app

泄露秘密 提交于 2020-01-01 07:58:08
问题 I have a Shiny app that uses the read.xlsx function from package xlsx . All works fine, but I want to change to read_excel from readxl , hoping it would be faster and able to cope with large files. ui part: fileInput("inputFile","Upload file...") server part: data <- reactive({ inFile <- input$inputFile if (is.null(inFile)) { return(NULL) } dataFile <- read_excel(inFile$datapath,sheet=1) return(dataFile) }) I get the "Unknown format" error. inFile$datapath is "/tmp/...

How to export an Excel sheet range to a picture, from within R

社会主义新天地 提交于 2020-01-01 02:39:16
问题 We are trying to automate the creation of some picture files within an R Script. We have the Excel files looking the way that we want them to, but now need to make a JPG or PNG picture-copy of those excel tables for easier web posting. We've been using the library(xlsx) package for most of our interactions between R and Excel, and it looks like we should be able to send specific java commands through something like ?.jmethods but it's unclear how we would pass as many lines as we need to. In