excel

Remove a worksheet in Excel using r package xlsx

馋奶兔 提交于 2021-02-07 09:14:26
问题 As the title stated, I would like to delete the second worksheet in excel using r with package xlsx. However, after running the code, nothing happened. Following is a sample code I used to delete the sheet: path = "C://ECOS//Code//Test//data.xlsx" sheets = getSheets(loadWorkbook(path)) removeSheet(loadWorkbook(path), sheetName = names(sheets[2])) Really appreciate helps. Thank you! 回答1: You need to save the workbook in the same file (or different if you prefer). wb = loadWorkbook(path)

Append data to an existing excel spreadsheet

有些话、适合烂在心里 提交于 2021-02-07 08:50:13
问题 I wrote the following function to accomplish this task. def write_file(url,count): book = xlwt.Workbook(encoding="utf-8") sheet1 = book.add_sheet("Python Sheet 1") colx = 1 for rowx in range(1): # Write the data to rox, column sheet1.write(rowx,colx, url) sheet1.write(rowx,colx+1, count) book.save("D:\Komal\MyPrograms\python_spreadsheet.xls") For every url taken from a given .txt file, I want to be able to count the number of tags and print that to each excel file. I want to overwrite the

Append data to an existing excel spreadsheet

隐身守侯 提交于 2021-02-07 08:47:51
问题 I wrote the following function to accomplish this task. def write_file(url,count): book = xlwt.Workbook(encoding="utf-8") sheet1 = book.add_sheet("Python Sheet 1") colx = 1 for rowx in range(1): # Write the data to rox, column sheet1.write(rowx,colx, url) sheet1.write(rowx,colx+1, count) book.save("D:\Komal\MyPrograms\python_spreadsheet.xls") For every url taken from a given .txt file, I want to be able to count the number of tags and print that to each excel file. I want to overwrite the

Converting xls to semicolon delimited csv with soffice commandline

半城伤御伤魂 提交于 2021-02-07 08:39:47
问题 I'm trying to convert xls files in a directory to csv format using soffice. soffice --headless --convert-to csv * It is giving comma separated version(obviously). Now I want to get semi-colon delimited csv. I thought of replacing commas with semi-colons using vim command. :%s/,/;/g But it's not correct, as it replaces commas which are kept intentionally in original content. It has to delimit while converting from xls to csv. How to get semi-colon delimited csv with soffice command line? 回答1:

Converting xls to semicolon delimited csv with soffice commandline

和自甴很熟 提交于 2021-02-07 08:39:06
问题 I'm trying to convert xls files in a directory to csv format using soffice. soffice --headless --convert-to csv * It is giving comma separated version(obviously). Now I want to get semi-colon delimited csv. I thought of replacing commas with semi-colons using vim command. :%s/,/;/g But it's not correct, as it replaces commas which are kept intentionally in original content. It has to delimit while converting from xls to csv. How to get semi-colon delimited csv with soffice command line? 回答1:

Excel to PostgreSQL using Python

↘锁芯ラ 提交于 2021-02-07 08:36:54
问题 I'm new to Python and I'm trying to export excel directly into postgreSQL without CSV files. I don't know if it's possible. I keep running into the error 'column "daily_date" is of type date but expression is of type numeric' . import psycopg2 import xlrd book = xlrd.open_workbook("pytest.xlsx") sheet = book.sheet_by_name("Source") database = psycopg2.connect (database = "RunP", user="postgres", password="", host="localhost", port="5432") cursor = database.cursor() query = """INSERT INTO

Formatting Excel cell from number to text in rails

落花浮王杯 提交于 2021-02-07 07:59:34
问题 I have made an application on which I have provide the feature to import the records from CSV and Excel file. I am using roo gem for it. The record added successfully but the problem is at the time of importing records from excel, it adds .0 to every field which is number. I don't want it because i have some fields like enrollment_no, roll_no, contact_no and it adds .0 to every filed like it made 23 to 23.0. I already had converted these filed to varchar in database and now i want to format

Preformat to currency and two decimal places in python using xlwt for excel

ε祈祈猫儿з 提交于 2021-02-07 07:48:10
问题 I have a column heading Fee . Using xlwt in python , I successfully generated the required excel.This column is always blank at the creation of Excel file. Is it possible to have the Fee column preformatted to 'Currency' and 'two decimal places', so that when I write manually in the Fee column of the Excel file after downloading, 23 should change into $23.00 ?? 回答1: I got it working like this: currency_style = xlwt.XFStyle() currency_style.num_format_str = "[$$-409]#,##0.00;-[$$-409]#,##0.00"

How to import a csv file using @ as delimiter with VBA

旧巷老猫 提交于 2021-02-07 07:15:50
问题 I am trying to load data from a csv file in Excel with VBA using ADODB. I have a function to return a Connection object. Private Function OpenConnection(dataSource As String) As ADODB.Connection Set OpenConnection = CreateObject("ADODB.Connection") With OpenConnection .ConnectionTimeout = 5 .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dataSource & ";" & _ "Extended Properties=""Text;HDR=YES;FMT=Delimited(,)"";Persist Security Info=False" Debug.Print "trying to connect

How to AutoFit excel column using OpenXML Package

柔情痞子 提交于 2021-02-07 06:32:28
问题 This code to generate Excel spreadsheet Using openxml package. Please anyone tell how to auto fit its column width. OpenXmlPackage.SpreadsheetDocument spreadsheetDocument = OpenXmlPackage.SpreadsheetDocument.Create(downloadFilePath, OpenXml.SpreadsheetDocumentType.Workbook); // Add a WorkbookPart to the document. OpenXmlPackage.WorkbookPart workbookpart = spreadsheetDocument.AddWorkbookPart(); // Add a WorksheetPart to the WorkbookPart. workbookpart.Workbook = new OpenXmlSpreadsheet.Workbook(