Converting a Python Float to a String without losing precision

I’m the author of xlrd. There is so much confusion in other answers and comments to rebut in comments so I’m doing it in an answer. @katriealex: “””precision being lost in the guts of xlrd””” — entirely unfounded and untrue. xlrd reproduces exactly the 64-bit float that’s stored in the XLS file. @katriealex: “””It may … Read more

Saving excel worksheet to CSV files with filename+worksheet name using VB [duplicate]

I think this is what you want… Sub SaveWorksheetsAsCsv() Dim WS As Excel.Worksheet Dim SaveToDirectory As String Dim CurrentWorkbook As String Dim CurrentFormat As Long CurrentWorkbook = ThisWorkbook.FullName CurrentFormat = ThisWorkbook.FileFormat ‘ Store current details for the workbook SaveToDirectory = “H:\test\” For Each WS In Application.ActiveWorkbook.Worksheets WS.SaveAs SaveToDirectory & WS.Name, xlCSV Next Application.DisplayAlerts = False … Read more

Using Python, write an Excel file with columns copied from another Excel file [closed]

Here are some options to choose from: xlwt (writing xls files) xlrd (reading xls/xlsx files) openpyxl (reading/writing xlsx files) xlsxwriter (writing xlsx files) If you need to copy only data (without formatting information), you can just use any combination of these tools for reading/writing. If you have an xls file, you should go with xlrd+xlwt … Read more

Merge and align center cell using apache poi

My solution was to merge the cells by their positions, then created a cell (reference to the first block of the merged cells) to assign a value and then set the alignment throught the CellUtil // Merges the cells CellRangeAddress cellRangeAddress = new CellRangeAddress(start, start, j, j + 1); sheet.addMergedRegion(cellRangeAddress); // Creates the cell Cell … Read more

How to close-without-save an Excel /xlsm workbook, w/ a custom function, from C#

When you use the Excel objects, be sure to close the workbook like this: Excel.Application xlApp ; Excel.Workbook xlWorkBook ; Excel.Worksheet xlWorkSheet ; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.ApplicationClass(); xlWorkBook = xlApp.Workbooks.Add(“Yourworkbook”); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); ….do your stuff xlWorkBook.Close(false, misValue, misValue); xlApp.Quit(); The false in the close method indicates don’t save changes.

Unprotect VBProject from VB code

I have never been in favor of Sendkeys. They are reliable in some case but not always. I have a soft corner for API’s though. What you want can be achieved, however you have to ensure that workbook for which you want to un-protect the VBA has to be opened in a separate Excel Instance. … Read more

Excel Select vs Activate

Select allows selecting several objects at once. Objects that are selected are placed in the Selection object, which permits iteration. Selecting an object (say, a column) activates the object. Activating an object makes it the active object. Best way to think of it is “many cells can be selected, but only one may be the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)