Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
thepiapus
Contributor II
Contributor II

Export to excel

Hi,

My code for export is:

sub Export_CrtneKode
	  Timestamp = Year(Date())&"-"&Month(Date())&"-"&Day(Date())
	'Create the Excel spreadsheet
	Set excelFile = CreateObject("Excel.Application")
	excelFile.Visible = false 'or false to run in background
  
    'Create the WorkBook
    Set curWorkBook = excelFile.WorkBooks.Add
    'Create the Sheet
    'first chart object
    Set curSheet = curWorkBook.WorkSheets(1)

	'paste the object
	Set i = ActiveDocument.GetSheetObject("CH02")
    i.CopyTableToClipboard true
	curSheet.Cells(1, 1).Select
	curSheet.Paste
	
	'to clear the clipboard
	curSheet.Cells(1, 100).Copy
	
	
	'define all cells format	
	curSheet.Columns("A").EntireColumn.NumberFormat = "0"
	curSheet.Columns(2).ColumnWidth = 50
	curSheet.Columns("B").EntireColumn.NumberFormat = "@"
	curSheet.Columns("C").EntireColumn.NumberFormat = "@"
	curSheet.Columns("D").EntireColumn.NumberFormat = "0"
	curSheet.Columns(5).ColumnWidth = 20
	curSheet.Columns("E").EntireColumn.NumberFormat = "@"
	curSheet.Columns("F").EntireColumn.NumberFormat = "@"
	curSheet.Columns("G").EntireColumn.NumberFormat = "@"
	curSheet.Columns("H").EntireColumn.NumberFormat = "@"
			
	excelFile.Visible = true
	'Save the file and quit excel
	excelFile.DisplayAlerts = False
	curWorkBook.SaveAs "S:\Porocanje QlikView\Izdelki Farmadent\ČRTNE KODE FD"&" "&timestamp&".xlsx"
	excelFile.DisplayAlerts = True
    curWorkBook.Close
    excelFile.Quit
    'Cleanup
    Set curWorkBook = nothing
    Set excelFile = nothing    

end sub

 Column E is EAN code formatted as text.  After export the cell is displayed e.g. 6,94952E+12 instead of 6949517000018.

Any idea how can I solve this?

TIA, Igor

  

10 Replies
thepiapus
Contributor II
Contributor II
Author

Thx....:-)