COMPILE SUBROUTINE REPORT_GAN_STATUS(dummy)

* GaN Process overview report


DECLARE SUBROUTINE ErrMsg
DECLARE FUNCTION obj_GaN, obj_Gan_Test, Environment_Services



EQU COL$STAGE			TO 1		;* Columns in return data
EQU COL$UNK_QTY1		TO 2
EQU COL$UNK_QTY2		TO 3
EQU COL$RDS_NO			TO 4
EQU COL$EPI_PART_NO		TO 5
EQU COL$GAN_RUN_ID		TO 6
EQU COL$STATE			TO 7
EQU COL$WFR_QTY			TO 8
EQU COL$TOOL_ID			TO 9

EQU CRLF$	TO \0D0A\

$INSERT EXCEL_EQU

DataArray = obj_GaN('GetStatus')

SWAP @VM WITH CHAR(9) IN DataArray
SWAP @FM WITH CRLF$ IN DataArray
CALL Set_Property('CLIPBOARD', 'TEXT', DataArray)


xlApp = OleCreateInstance("excel.Application")								;* Create instance of Excel


IF OleStatus() THEN
	
	PasteBlob = DataArray
	
	CALL Set_Property('CLIPBOARD', 'TEXT', PasteBlob)
	
	ErrorMsg  = 'Excel failed to start.':CRLF$:CRLF$
	ErrorMsg := 'The data from this export is on your clipboard and can be pasted into Excel on your local machine using <Ctrl><V> .'
	
	ErrMsg(ErrorMsg)
	
	
	RETURN
	
END


OlePutProperty(XlApp, 'Visible', xlSheetVisible)
if OleStatus() then Goto HadError

xlWorkBooks =OleGetProperty(xlApp, "Workbooks")								;* Create workbook
xlWkb = OleCallMethod(xlWorkbooks,"Add")
if OleStatus() then Goto HadError

xlSht = OleGetProperty(xlWkb, "Worksheets",1)								;* Select worksheet 1
if OleStatus() then Goto HadError

xlPageSetup = OleGetProperty(xlSht,"PageSetup")								;* Get PageSetup object for Page/Printing stuff
if OleStatus() then GOTO HadError

OlePutProperty( xlPageSetup , 'PrintGridLines', xlTrue )										;* Print Gridlines on
OlePutProperty( xlPageSetup , 'Orientation' , xlLandscape )										;* Orientation to Landscape
OlePutProperty( xlPageSetup , 'HeaderMargin', '20')												;* HeaderMargin to 20pts

OlePutProperty( xlPageSetup , 'CenterHeader' , '&14Epi SERVICES - Thruput Report - w/o Makeup Activity' )		;* Set Center Header
OlePutProperty( xlPageSetup , 'LeftHeader' , '&G' )												;* Set graphic in Left Header

graphic = OleGetProperty( xlPageSetup , 'LeftHeaderPicture' )									;* Get graphic object for Left Header Picture
OlePutProperty( graphic , 'FileName' , 'R:\Oinsight\BMPS\EpiSvcs.png' )							;* Set filename for graphic
OlePutProperty( graphic , 'Height' , '51.75' )													;* Scale graphic to fit header		
OlePutProperty( graphic , 'Width' , '81')

OlePutProperty( xlPageSetup , 'RightHeader' , 'Page &P' )					;* Set Right Header to show current page number


ColCnt = COUNT(DataArray,@FM) + (DataArray NE '')
LineCnt = COUNT(DataArray<1>,@VM) + (DataArray<1> NE '')
FOR LineNo = 1 TO LineCnt
	FOR Column = 1 to ColCnt
		RangeColumn = eXcelCols<1,Column>
		range = OleGetProperty( xlSht, 'Range',RangeColumn:LineNo)
		OlePutProperty(range, 'Value', DataArray<Column,LineNo>)			;* Load report array into spreadsheet cells
		IF OleStatus() THEN GOTO HadError
	NEXT Column
NEXT LineCnt

LastColumn = eXcelCols<1,ColCnt>
range = OleGetProperty( xlSht, 'Range','B1:':LastColumn:'1')				;* Turn on word wrap in columns from B through end
OlePutProperty( range, 'WrapText', xlTrue)
IF OleStatus() THEN GOTO HadError

RangeColumn = eXcelCols<1,ColCnt>
range = OleGetProperty( xlSht, 'Range','A1:':RangeColumn:LineCnt)

Void = OleCallMethod( range, 'AutoFormat', xlRangeAutoFormatClassic1 )		;* Turn on autoformat (FormatClassic1)
IF OleStatus() THEN GOTO HadError

/*
FOR I = COL$MON TO COL$SUN
	eXcelCol = eXcelCols<1,I>
	column = OleGetProperty( xlSht, 'Range' , eXcelCol:':':exCelCol )		;* Set the day columns to a standard width
	OlePutProperty( column , 'ColumnWidth' , '10.6' )						;* Originally 10.3 - changed to 10.6 to fit Wednesday - dkk 12/30/13
	a = OleStatus()
NEXT I


EdgeList = xlDiagonalDown:@VM:xlDiagonalup:@VM:xlEdgeLeft:@VM:xlEdgeTop:@VM:xlEdgeRight:@VM:xlInsideVertical

* Put border on the BOTTOM of this row

range = OleGetProperty( xlSht, 'Range', 'A':ROW$TOT_SHIP:':':RangeColumn:ROW$TOT_SHIP)

FOR I = 1 TO COUNT(EdgeList,@VM) + (EdgeList NE '')
	edge = OleGetProperty( range, 'Borders' , EdgeList<1,I> )
	OlePutProperty( edge , 'LineStyle' , xlLineStyleNone )					;* Clear border segments EXCEPT bottom
	IF OleStatus() THEN debug
NEXT I

edge = OleGetProperty( range, 'Borders' , xlEdgeBottom )					;* Set border segment for bottom to medium weight line
olePutProperty( edge , 'LineStyle', xlContinuous )
olePutProperty( edge , 'Weight' , xlMedium )
olePutProperty( edge , 'ColorIndex', xlColorIndexAutomatic )

range = OleGetProperty( xlSht, 'Range', 'A':ROW$MER_SHIP:':':RangeColumn:ROW$MER_SHIP)	;* Set border for range (underline entire row)

FOR I = 1 TO COUNT(EdgeList,@VM) + (EdgeList NE '')
	edge = OleGetProperty( range, 'Borders' , EdgeList<1,I> )				
	OlePutProperty( edge , 'LineStyle' , xlLineStyleNone )
NEXT I

edge = OleGetProperty( range, 'Borders' , xlEdgeBottom )
olePutProperty( edge , 'LineStyle', xlContinuous )
olePutProperty( edge , 'Weight' , xlMedium )
olePutProperty( edge , 'ColorIndex', xlColorIndexAutomatic )
*/

* Void = OleCallMethod( xlWkb, 'SaveAs','C:\OIReports\ThruPut.xls', xlWorkbookNormal )		;* Save to local drive
Void = OleCallMethod( xlWkb, 'SaveAs',Environment_Services('GetReportsRootPath') : '\ThruPut.xls', xlWorkbookNormal )		;* Save to local drive



RETURN



* * * * * * *
HadError:
* * * * * * *
	
	xlChart = ''
	Charts = ''
	range = ''
	xlSht = ''
	xlWkb=''
	xlWorkBooks = ''
	x = OleCallMethod(xlApp, 'Quit')
	
RETURN 


