CSV import crashing in Calc / LibreOffice 7.6

I migrated from 7.5 to 7.6.0.3 this weekend on my Windows 10 laptop (details below). Running into trouble withy a few of my macro’s in Calc. I use them to process CSV-files which I download from my bank. The macro moves and opens the file and processes the content. They worked flawless in LO 7.5.

In version 7.6, these macro’s consistently crash early in the process. I have narrowed it down to roughly somewhere in the code below. Studying the release notes (which I did before migrating) does not give me any clue as to what causes this problem, and I have not seen other reports of this problem. Anybody an idea or similar experience?

The error I get is the following:

BASIC runtime error.
An exception occurred
Type: com.sun.star.uno.RuntimeException
Message: [mscx_uno bridge error] UNO type of C++ exception unknown: “std.system_error”, RTTI-name = “.?AVsystem_error@std@@”!.


Sub ImportFromMyBank()
	
	'Here is some initial code

	'Somewhere in the section below the macro and Calc crash.

	'Move file to Archive Directory
	FromPath = ThisComponent.NamedRanges.getByName("DirDownloads").getReferredCells.String
	ToPath = ThisComponent.NamedRanges.getByName("DirArchiveMyBank").getReferredCells.String
	ImportFileName = Dir(FromPath & "CSV_?_*.csv")
	ImportFileFullName = FromPath & ImportFileName
	
	If FileExists(ImportFileFullName) Then
		NewFullFileName = ToPath + ImportFileName
	Else
		MsgBox ("MyBank file does not exist.", MB_OK + MB_ICONINFORMATION, "GnuCash Converter")
		Exit Sub
	End If

	FileCopy ImportFileFullName, NewFullFileName
	Kill ImportFileFullName
   
	'Open requested xMyBank file and copy data
	path = ConvertToURL(NewFullFileName)

	opt(0).Name = "Hidden" 'the document will open hidden
	opt(0).Value = True
	opt(1).Name = "FilterName"
	opt(1).Value = "Text - txt - csv (StarCalc)"
	opt(2).Name = "FilterOptions"
	opt(2).Value = "44,34,0,0,1/2/2/2/3/2/4/1/5/4/6/4/7/1/8/1/9/2/10/2/11/2/12/2/13/2/14/2/15/2/16/2/17/2/18/2/19/2/20/2/21/2/22/2/23/2/24/2/25/2/26/2,1,false,false,false,false,false"

	cell = ThisComponent.Sheets.getByName("Data").getCellRangeByName("A1") 'The "Data" worksheet exists, it is created in the Initial Code
	target = next_cell(cell)
	
	csv = StarDesktop.loadComponentFromURL(path, "_blank", 0, opt())
	sheet = csv.Sheets.getByIndex(0)
	cell = sheet.getCellRangeByName("A1")
	cursor = sheet.createCursorByRange(cell)
	cursor.collapseToCurrentRegion()
	ra = cursor.RangeAddress

	data = sheet.getCellRangeByPosition(ra.StartColumn, ra.StartRow, ra.EndColumn, ra.EndRow).DataArray
	copy_to(target, data)
	csv.close(True)

	'Here follows the rest of the macro processing the file

End Sub

	'----------- GENERIC FUNCTIONS -------------------

Function copy_to(cell, data)
	ra = cell.RangeAddress
	s = cell.SpreadSheet
	cols = ra.EndColumn + UBound(data(0))
	rows = ra.EndRow + Ubound(data)
	range = s.getCellRangeByPosition(ra.StartColumn, ra.StartRow, cols, rows)
	range.DataArray = data
	
End Function

Function next_cell(cell)

	cursor = cell.SpreadSheet.createCursorByRange(cell)
	cursor.gotoEnd()
	row = cursor.RangeAddress.EndRow
	next_cell = cell.SpreadSheet.getCellByPosition(0, row + 1)

End Function


Version: 7.6.0.3 (X86_64) / LibreOffice Community
Build ID: 69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265
CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: threaded

Nothing in release notes could ever legitimize a crash :smiley:
So if your code crashed the program, this is definitely a bug, and needs a bug report. Being a crasher, it has a high priority. Being a regression, it has even higher priority :slight_smile: - just don’t forget to provide a sample CSV to the bug report, to allow easy reproduction.

Thanks, will do.

Please don’t forget to post a link to the bug report here. CSV’s are life-blood to my use of LO, and having a link here makes this topic searchable from AskLO. Meanwhile, FWIW, I’ll try out 7.6.0.3 and see if my usage results in any peculiarities.

Please find enclosed this link to the bug report.

2 Likes