Hi Kirk,
Just found your post to the SUG again whilst looking for
something else.
Quick question - did you mange to get anywhere?
Kind regards,
Huw
···
On 10/03/2019 16:02, Huw Pearce
[sailwave] wrote:
Hi Kirk,
That would be fantastic if you are able to provide Jon
with a solution to interface to LibreOffice. What would be
even better if it then would work when Sailwave run under
WINE on Linux & MacOS.
Look forward to seeing what you come up with.
Kind regards,
Huw
On 10/03/2019 15:27, Kirk
Robertson [sailwave] wrote:
beat me to it. will see what I can find
On Sun, Mar 10, 2019
at 11:32 AM Jon Eskdale jon@sailwave.com
[sailwave] <sailwave@yahoogroups.com >
wrote:
Hi Kirk,
If you can supply a Com automation
documentation that works similar to
the Excel which allows Sailwave to
read and write cells of the
spreadsheet individually and as a
range plus enable/disable auto
calculation and perform calculation
Below is the class which I've
developed for allowing me to
communicate with Excel. If you can
supply documentation to allow me to do
the same with Libre office I will see
what I can do.
Jon
’ http://msdn.microsoft.com/en-us/library/bb978779(v=office.12).aspx
’
’ All functions
'http://office.microsoft.com/en-us/excel-help/excel-functions-by-category-HP005204211.aspx?redir=0
CLASS CXL
INSTANCE m_FileName AS
STRING
INSTANCE m_oExcelApp AS
Excel_Application
INSTANCE m_oExcelWorkbook AS
Excel_Workbook
INSTANCE m_vExcelWorkbook AS
VARIANT
INSTANCE m_oExcelWorkSheet AS
Excel_WorkSheet
INSTANCE m_vExcelWorkSheet AS
VARIANT
INSTANCE vFalse AS
VARIANT
INSTANCE vTrue AS
VARIANT
'INSTANCE
Xl
instance XlEvents as
AppEvents
INTERFACE IXL : INHERIT
IAUTOMATION
PROPERTY GET XLFile() AS
STRING : PROPERTY = m_FileName :
END PROPERTY
PROPERTY SET XLFile( BYVAL
sFileName AS STRING) : m_FileName =
sFileName : END PROPERTY
METHOD Init()
vFalse = 0
vTrue = 1
’ Open an instance of EXCEL
m_oExcelApp = ANYCOM
$PROGID_Excel_Application
' Could EXCEL be opened? If
not, terminate this app
IF ISFALSE
ISOBJECT(m_oExcelApp) OR ERR THEN
outputdebugstring
"Error " & Str$(ERR) & " "
& $PROGID_Excel_Application
MSGBOX "Excel could not
be opened. Please check that Excel
and VBA are installed.",“SWHelper -
Error”
EXIT METHOD
ELSE
OBJECT LET
m_oExcelApp…Visible = vTrue
END IF
'
Create the Events handler interface
XlEvents
= CLASS “Class_AppEvents”
IF
ISFALSE(ISOBJECT(XlEvents)) THEN
msgbox("Error
creating the event interface.")
END
IF
'
Attach the Events handler interface
to the Agent Control
EVENTS
FROM m_oExcelApp CALL XlEvents
END METHOD
METHOD Unload()
SET m_oExcelApp =
NOTHING
SET m_oExcelWorkbook =
NOTHING
SET m_oExcelWorkSheet =
NOTHING
set
XlEvents
= nothing
END METHOD
’ Open file
METHOD OPEN(FileN AS STRING)
LOCAL vInFile AS VARIANT
vInFile = FileN
OBJECT CALL
m_oExcelApp.WorkBooks.Open(Filename
= vInFile, UpdateLinks=vFalse) TO
m_vExcelWorkbook
SET m_oExcelWorkbook =
m_vExcelWorkbook
END METHOD
’ Close File
METHOD CLOSE(FileN AS STRING)
IF FileN = “” THEN
try
OBJECT
CALL
m_oExcelWorkbook.Close(SaveChanges=vFalse)
catch
outputdebugstring
“Close XL in Class failed probably
because someone manually closed it”
end
try
END IF
END METHOD
’ Select WorkSheet
METHOD SelectWS(WorkSheet AS
STRING)
LOCAL vInSheet AS VARIANT
vInSheet = WorkSheet
OBJECT CALL
m_oExcelApp.Sheets(vInSheet).SELECT
OBJECT GET
m_oExcelApp.ActiveSheet TO
m_vExcelWorkSheet
SET m_oExcelWorkSheet =
m_vExcelWorkSheet
END METHOD
’ Get used Cells to array
METHOD GetUsed()
LOCAL lbrow AS
LONG
LOCAL ubrow AS
LONG
LOCAL lbcol AS
LONG
LOCAL ubcol AS
LONG
LOCAL lrow AS
LONG
LOCAL lcol AS
LONG
LOCAL lvType AS
LONG
LOCAL vNoParenArray AS
VARIANT
DIM vTwoDimArray(0) AS
VARIANT
local
w as
wstring
OBJECT GET
m_oExcelWorkSheet.UsedRange.Value TO
vNoParenArray
LET vTwoDimArray() =
vNoParenArray
lbrow =
LBOUND(vTwoDimArray(),1)
ubrow =
UBOUND(vTwoDimArray(),1)
lbcol =
LBOUND(vTwoDimArray(),2)
ubcol =
UBOUND(vTwoDimArray(),2)
REDIM sArray(lbrow TO
ubrow, lbcol TO ubcol)
FOR lrow = lbrow TO ubrow
FOR lcol = lbcol TO
ubcol
lvType =
VARIANTVT(vTwoDimArray(lrow,lcol))
IF lvType = 0 OR
lvType = 1 THEN ’ nothing or null
ELSEIF lvType = 8
THEN 'string
w
= variant$$(vTwoDimArray(lrow,lcol))
'outputdebugstring
"variant " + w
sArray(lrow,lcol)
= w
ELSEIF lvType => 2
AND lvType <= 6 THEN
sArray(lrow,lcol)
=
FORMAT$(VARIANT#(vTwoDimArray(lrow,lcol)))
ELSE
sArray(lrow,lcol)
= “unknown”
END IF
NEXT
NEXT
END METHOD
method
StoreRange(Param1 as string, Param2
as string)
dim
vArray as
variant
dim
vParam1 as
Variant
dim
vParam2 as
variant
vParam1
= Param1
vParam2
= Param2
vArray
= sInArray()
object
let
m_oExcelWorkSheet.Cells.Range(vParam1,
vParam2) = vArray
END METHOD
method
StoreValue(c as string, value as
String)
local
vCell as
variant
local
vValue as
Variant
vCell
= c
vValue
= value
object
let
m_oExcelWorkSheet.Range(vCell).value
= vValue
END METHOD
method
ReadString(c as string) as string
local
vCell as
variant
local
vValue as
Variant
local
w as
wstring
vCell
= c
object
get
m_oExcelWorkSheet.Range(vCell).value
to vValue
w
= Variant$$(vValue)
method
= w
END METHOD
method
ReadNumeric(c as string) as double
local
vCell as
variant
local
vValue as
Variant
local
w as
wstring
vCell
= c
object
get
m_oExcelWorkSheet.Range(vCell).value
to vValue
method
= Variant#(vValue)
END METHOD
method
ScreenUpdating(b as long)
local
v as Variant
v
= b
object
let m_oExcelApp.ScreenUpdating = v
END METHOD
method
EnableCalculation(b as long)
local
v as Variant
v
= b
object
let
m_oExcelWorkSheet.EnableCalculation
= v
END METHOD
'
Set Calcultion mode can be
xlCalculationManual,
xlCalculationAutomatic or
xlCalculationSemi
method
SetCalculationMode(b as long)
local
v as Variant
v
= b
object
let m_oExcelApp.Calculation = v
END METHOD
Method
GetCalculationState() as long
Local
vValue as
variant
object
Get m_oExcelApp.CalculationState to
vValue
Method
= VARIANT#(vValue)
END METHOD
METHOD
CalcNow()
Object
call m_oExcelApp.Calculate()
END METHOD
METHOD
CalcWSNow()
Object
call m_oExcelWorkSheet.Calculate()
END METHOD
END INTERFACE
END CLASS
Jon
Eskdale
03333 443377
07530 112233
On Sun,
10 Mar 2019 at 15:10, Kirk Robertson jkirkrobertson@gmail.com
[sailwave] <sailwave@yahoogroups.com >
wrote:
I know
you are all pretty busy
right and am not begging.
But has
any thought been given to
supporting Libre Office as
alternative to Microsoft.
Must
admit I like Libre Office so
much, I have donated to
project (not that my
donation(s) amounts to “a
hill of beans”).
Would be
neat to have interface to
its spreadsheet
Sent from
for Windows 10
** From:** Huw
Pearce
huw.pearce@bcs.org.uk
[sailwave]
Sent: Sunday,
March 10, 2019 11:05 AM
To: sailwave@yahoogroups.com
Subject: Re:
[sailwave] sailwave and
Libre Office
Hi Kirk,
In what way do you
want to Sailwave to to
be used with
LibreOffice? I have
successfully published
to LibreOffice Writer
& LibreOffice
Calc. However if you
mean using LibreOffice
Calc as an alternative
to Microsoft Excel for
external RYA NHC use
then the answer is no.
Sailwave uses
Microsoft messaging
API’s to communicate
with Excel which do
not work with
LibreOffice which has
a different API.
PS - I see Jon has
already replied
Kind regards,
Huw
On
10/03/2019 14:27, kirkrobertson406@yahoo.com
[sailwave] wrote:
Has anyone
successfully used
Sailwave with
Libre Office
instead of
Microsoft Office
Virus-free.