Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 7 Jahren, 9 Monaten
Letzter Beitrag:
vor 6 Jahren, 4 Monaten
Beteiligte Autoren:
CCC2, Merijn van der Wijk, Georgio, Arie

can WD create xlsx

Startbeitrag von Arie am 18.11.2010 13:54

Hi,
one of my clients asks me, if my applications can create XLSX files. Can WD do that?
The docs say it is just a matter of using the right extension and the conversion is done on the fly.
But is this conversion done, while opening the file in Excel? Or does WD really create the XLSX format?

Currently I need this for the TableToExcel() function.

Antworten:

Hi Arie,

XLSX is stored in a text file format (similar to CSV) and there is no macro support.
So, Windev has to be doing it for you; not on the fly.

Thanks
Georgio

von Georgio - am 18.11.2010 15:55
Hi Arie,

After submitting this problem to PCsoft they stated:
This problem occurs when WD160ZIP.DLL is not used by the project or is not found. Is it the case here ?

When debugging the TableToExcel failed.

Therefore I explicitly loaded the DLL which did not help, using LoadDLL.

Three solutions:
1. When creating the executable in step 6 Framework (2/2)
- load the WD160ZIP.DLL 'When started' instead of 'First use'
2. Before using the TableToExcel load the WD160ZIP.DLL, e.g.:
- zipCreate("test","c:\tmp" )
3. PCsoft fixes this problem

Rationale:
When the Wlanguage call TableToExcel is fired the WD160XLS.DLL is loaded into memory.
Creating a XLS file will be no problem, however creating a XLSX file the WD160ZIP.DLL is needed (because xlsx is a compressed format) but not loaded.


Greetings
Merijn

von Merijn van der Wijk - am 17.04.2012 10:03
Hi ,

for years I have been using object Automation to handle excel .

for those that interest, here I attach the class that I create and use all these years ,


CCExcel2 is class
PRIVATE
m_Excel is object Automation dynamic
m_WorkSheet is int = 1
m_opentype is int = 0 // 1 is new , 2 is open

PUBLIC
XLS_MsgError is string

PUBLIC CONSTANT
ALIGN_LEFT is int = -4131
ALIGN_CENTER is int = -4108
ALIGN_RIGHT is int = -4152

///max color 56
COLOR_BLACK is int = 1
COLOR_WHITE is int = 2
COLOR_RED is int = 3
COLOR_GREEN is int = 4
COLOR_BLUE is int = 5
COLOR_YELLOW is int = 6
COLOR_MAGENTA is int = 7
COLOR_CYAN is int = 8


END


PROCEDURE Constructor()


PROCEDURE Destructor()


// Summary:
// Syntax:
//[ = ] XLS_Open ( is string)
//
// Parameters:
// Arg_fileName (string):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_Open(Arg_fileName is string)

:XLS_MsgError = ""
WHEN EXCEPTION IN

:m_Excel = GetActiveObject("Excel.Application")
IF :m_Excel = Null THEN
// Start Excel
:m_Excel = new object Automation "Excel.Application"
END

IF :XLS_IsFileOpen(Arg_fileName) = True THEN ExceptionThrow(1,"File " +Arg_fileName +" is in USE")
:m_Excel>>Workbooks>>Open(Arg_fileName)

:m_opentype = 2

RESULT True

DO
:XLS_MsgError = "Unable to Open Excel File (" + Arg_fileName + ")" +Charact(13) +
ExceptionInfo()

RESULT False

END




// Summary:
// Syntax:
//[ = ] XLS_Close ()
//
// Parameters:
// None
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
// Arg_save (boolean - default value=0):
// Arg_NewFileName (string):
PROCEDURE XLS_Close()

:XLS_MsgError = ""
WHEN EXCEPTION IN

IF :m_Excel Null THEN
IF :m_opentype > 0 THEN
:m_Excel>>ActiveWorkbook>>Close(False)
END

:m_Excel>>Application>>Quit

END

:m_opentype = 0
RESULT True

DO
:XLS_MsgError = "Unable to Close Excel" + Charact(13) +
ExceptionInfo()

RESULT False

END

// Summary:
// Syntax:
//[ = ] XLS_CurrentWorksheet ( [ is int])
//
// Parameters:
// Arg_Sheet (int - default value=0):
// Return Value:
// int: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_CurrentWorksheet(Arg_Sheet is int = 0)

:XLS_MsgError = ""
WHEN EXCEPTION IN

IF Arg_Sheet = 0 THEN
RESULT :m_WorkSheet
END

:m_Excel>>ActiveWorkbook>>Sheets(Arg_Sheet)>>Select()
:m_WorkSheet = Arg_Sheet

RESULT :m_WorkSheet

DO
:XLS_MsgError = "Unable to Change Active WorkSheet" +Charact(13) +
ExceptionInfo()
RESULT 0

END



// Summary:
// Syntax:
//[ = ] XLS_NbRow ()
//
// Parameters:
// None
// Return Value:
// int: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_NbRow()
m_row is int = 0

:XLS_MsgError = ""
WHEN EXCEPTION IN
:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>UsedRange()
m_row = :m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Cells( :m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Cells>>Rows>>Count, "A")>>End(-4162)>>Row

DO

:XLS_MsgError = "Unable to get Row Count " +Charact(13) +
ExceptionInfo()

END

RESULT m_row


// Summary:
// Syntax:
//[ = ] XLS_NbColumn ()
//
// Parameters:
// None
// Return Value:
// int: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_NbColumn()
m_col is int = 0

:XLS_MsgError = ""
WHEN EXCEPTION IN
m_col = :m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>UsedRange>>Columns>>Count

DO

:XLS_MsgError = "Unable to get Column Count " +Charact(13) +
ExceptionInfo()

END

RESULT m_col



// Summary:
// Syntax:
//[ = ] XLS_NbWorksheet ()
//
// Parameters:
// None
// Return Value:
// int: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_NbWorksheet()
m_SheetCount is int = 0

:XLS_MsgError = ""
WHEN EXCEPTION IN
m_SheetCount = :m_Excel>>ActiveWorkbook>>Worksheets>>Count

DO

:XLS_MsgError = "Unable to get Sheet Count " +Charact(13) +
ExceptionInfo()

END

RESULT m_SheetCount


// Summary:
// Syntax:
//[ = ] XLS_SheetName ( is int)
//
// Parameters:
// Arg_SheetNo (int):
// Return Value:
// string: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_SheetName(Arg_SheetNo is int)
m_SheetName is string = ""

WHEN EXCEPTION IN


m_SheetName = :m_Excel>>ActiveWorkbook>>sheets(Arg_SheetNo)>>name


DO
:XLS_MsgError = "Unable to get Sheet Name (Sheet No " + Arg_SheetNo + ")" +Charact(13) +
ExceptionInfo()

END

RESULT m_SheetName
// Summary:
// Syntax:
//[ = ] XLS_CellRead ( is int, is int)
//
// Parameters:
// Arg_row (int):
// Arg_column (int):
// Return Value:
// string: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_CellRead(Arg_row is int , Arg_column is int)
m_str is string = ""

:XLS_MsgError = ""
WHEN EXCEPTION IN

m_str = :m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>cells(Arg_row,Arg_column)>>value

DO

:XLS_MsgError = "Unable to Read Cell Content " + Charact(13) +
"Row : " + Arg_row +Charact(13)+
"Col : " + Arg_column +Charact(13)+
ExceptionInfo()


END

RESULT m_str



// Summary:
// Syntax:
//[ = ] XLS_CellWrite ( is int, is int [, is string [, is int [, is int [, is int]]]])
//
// Parameters:
// Arg_row (int):
// Arg_column (int):
// Arg_Str (string):
// Arg_align (int - default value=0):
// Arg_BGcolor (int - default value=0):
// Arg_FontColor (int - default value=0):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_CellWrite(Arg_row is int ,
Arg_column is int,
Arg_Str is string = "",
Arg_align is int = 0,
Arg_BGcolor is int = 0,
Arg_FontColor is int = 0)

:XLS_MsgError = ""
WHEN EXCEPTION IN

:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>cells(Arg_row,Arg_column)>>value = Arg_Str

IF Arg_align 0 THEN
:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>cells(Arg_row,Arg_column)>>HorizontalAlignment = Arg_align
END

IF Arg_BGcolor 0 THEN
:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>cells(Arg_row, Arg_column)>>Interior>>ColorIndex = Arg_BGcolor
END

IF Arg_FontColor 0 THEN
:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>cells(Arg_row, Arg_column)>>Font>>ColorIndex = Arg_FontColor
END

RESULT True

DO

:XLS_MsgError = "Unable to Write to Cell " + Charact(13) +
"Row : " + Arg_row + Charact(13) +
"Col : " + Arg_column + Charact(13) +
"Content : " +Arg_Str + Charact(13) +
ExceptionInfo()

RESULT False
END



// Summary:
// Syntax:
//[ = ] XLS_New ()
//
// Parameters:
// None
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_New()

:XLS_MsgError = ""
WHEN EXCEPTION IN
:m_Excel = GetActiveObject("Excel.Application")
IF :m_Excel = Null THEN
// Start Excel
:m_Excel = new object Automation "Excel.Application"
END

:m_Excel>>Workbooks>>Add
:m_opentype = 1
RESULT True
DO
:XLS_MsgError = "Unable to Create New WorkBook " +Charact(13) +
ExceptionInfo()

RESULT False
END



// Summary:
// Syntax:
//[ = ] XLS_SheetClear ( is int)
//
// Parameters:
// Arg_SheetNo (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_SheetClear(Arg_SheetNo is int)

WHEN EXCEPTION IN


:m_Excel>>ActiveWorkbook>>sheets(Arg_SheetNo)>>Cells>>Clear()

RESULT True

DO
:XLS_MsgError = "Unable to Clear Sheet (Sheet No " + Arg_SheetNo + ")" +Charact(13) +
ExceptionInfo()
RESULT False
END



// Summary:
// Syntax:
//[ = ] XLS_ColumnWidth ( is int, is int)
//
// Parameters:
// arg_column (int):
// arg_Width (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
// arg_column (int):
// arg_columnWidth (int):
PROCEDURE XLS_ColumnWidth(arg_column is int, arg_Width is int)

:XLS_MsgError = ""
WHEN EXCEPTION IN

:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Columns(arg_column)>>ColumnWidth = arg_Width

RESULT True

DO

:XLS_MsgError = "Unable to Change Column Width (Column : " + arg_column + ")" +Charact(13) +
ExceptionInfo()
RESULT False
END



// Summary:
// Syntax:
//[ = ] XLS_ColumnAlignment ( is int, is int)
//
// Parameters:
// arg_column (int):
// Arg_Align (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_ColumnAlignment(arg_column is int, Arg_Align is int)

:XLS_MsgError = ""
WHEN EXCEPTION IN


:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Columns(arg_column)>>Cells>>HorizontalAlignment = Arg_Align


RESULT True

DO
:XLS_MsgError = "Unable to Change Column Alignment (Column : " + arg_column + ")" + Charact(13) +
ExceptionInfo()

RESULT False

END




// Summary:
// Syntax:
//[ = ] XLS_ColumnBGcolor ( is int, is int)
//
// Parameters:
// arg_Column (int):
// Arg_Color (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_ColumnBGcolor(arg_Column is int, Arg_Color is int)

:XLS_MsgError = ""
WHEN EXCEPTION IN


:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Columns(arg_Column)>>Cells>>Interior>>ColorIndex = Arg_Color


RESULT True

DO
:XLS_MsgError = "Unable to Change Column BGColor (Column : " + arg_Column + ")" + Charact(13) +
ExceptionInfo()
RESULT False

END


// Summary:
// Syntax:
//[ = ] XLS_RowBGcolor ( is int, is int)
//
// Parameters:
// Arg_row (int):
// arg_color (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_RowBGcolor(Arg_row is int , arg_color is int)

:XLS_MsgError = ""
WHEN EXCEPTION IN


:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Rows(Arg_row)>>Cells>>Interior>>ColorIndex = arg_color


RESULT True

DO
:XLS_MsgError = "Unable to Change Row BG Color (Row : " + Arg_row + ")" +Charact(13) +
ExceptionInfo()
RESULT False

END


// Summary:
// Syntax:
//[ = ] XLS_ColumnFontcolor ( is int, is int)
//
// Parameters:
// arg_Column (int):
// Arg_Color (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
// arg_Column (int):
// Arg_Color (int):
PROCEDURE XLS_ColumnFontcolor(arg_Column is int, Arg_Color is int)

:XLS_MsgError = ""
WHEN EXCEPTION IN


:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Columns(arg_Column)>>Cells>>Font>>ColorIndex = Arg_Color


RESULT True

DO
:XLS_MsgError = "Unable to Change Column Font Color (Column : " + arg_Column + ")" +Charact(13) +
ExceptionInfo()
RESULT False

END


// Summary:
// Syntax:
//[ = ] XLS_RowFontcolor ( is int, is int)
//
// Parameters:
// Arg_row (int):
// arg_color (int):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
// Arg_row (int):
// arg_color (int):
PROCEDURE XLS_RowFontcolor(Arg_row is int , arg_color is int)

:XLS_MsgError = ""
WHEN EXCEPTION IN


:m_Excel>>ActiveWorkbook>>Worksheets(:m_WorkSheet)>>Rows(Arg_row)>>Cells>>Font>>ColorIndex = arg_color


RESULT True

DO
:XLS_MsgError = "Unable to Change Row Font Color (Row : " + Arg_row + ")" +Charact(13) +
ExceptionInfo()
RESULT False

END


// Summary:
// Syntax:
//[ = ] XLS_IsFileOpen ( is string)
//
// Parameters:
// Arg_FileName (string):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_IsFileOpen(Arg_FileName is string)
m_cnt is int

:XLS_MsgError = ""
WHEN EXCEPTION IN


FOR m_cnt = :m_Excel>>Workbooks>>count TO 1 STEP -1
IF Upper(:m_Excel>>Workbooks(m_cnt)>>FullName) = Upper(Arg_FileName) THEN
RESULT True
END
END


RESULT False

DO
:XLS_MsgError = "Exception in XLS_IsFileOpen ( File" + Arg_FileName + ")" +Charact(13) +
ExceptionInfo()

RESULT False

END






// Summary:
// Syntax:
//[ = ] XLS_Save ( [ is string])
//
// Parameters:
// Arg_NewFileName (string):
// Return Value:
// boolean: // None
//
// For instance:
// Indicate an example.
//
PROCEDURE XLS_Save(Arg_NewFileName is string = "")

:XLS_MsgError = ""
WHEN EXCEPTION IN

IF Arg_NewFileName = "" THEN
:m_Excel>>ActiveWorkbook>>Save

ELSE
IF :XLS_IsFileOpen(Arg_NewFileName) = True THEN ExceptionThrow(1, "Unable Save to (" + Arg_NewFileName + ") , File in Use")
:m_Excel>>ActiveWorkbook>>SaveAS(Arg_NewFileName)

END

RESULT True
DO
:XLS_MsgError = "Unable to Save Excel File" +CR +
ExceptionInfo()
RESULT False

END

von CCC2 - am 17.04.2012 16:02
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.