TemplatePath = "#{Dir.pwd}/Templates/Work_Request_Volume_Template.xls"

def get_workbook_filename(reqVol) #RequestVolume on the C# side
	"#{Dir.pwd}/#{reqVol.craftsperson.upcase}-#{reqVol.fiscal_year}.xls".to_clr_string
end

def setup_assigned_completed(reqVol, sheet)
	reqVol.each do |monthVol| #MonthVolume on the C# side
		row = sheet.Cells.Find(monthVol.month_name).Row
		sheet.Range("B#{row}", "C#{row}").Value2 = [monthVol.assigned, monthVol.completed]
	end
end

def finalize_volume_chart(reqVol, sheet)
	chart = sheet.ChartObjects("Chart 6").Chart
	chart.Axes(2).MaximumScaleIsAuto = true
	chart.Axes(1, 1).AxisTitle.Characters.Text = "Fiscal Year #{reqVol.fiscal_year}"
	chart.ChartTitle.Characters.Text = reqVol.craftsperson
end

def build_workbook(reqVol) #RequestVolume on the C# side
	Workbook.with_path(TemplatePath) do |workbook|
		setup_assigned_completed(reqVol, workbook.Worksheets(2))
		finalize_volume_chart(reqVol, workbook.Worksheets(1))
		
		@filename = get_workbook_filename(reqVol)
		workbook.SaveCopyAs(@filename)
	end
	
	return @filename
end

filenames = System::Collections::Generic::List[System::String].new
callerInput.each {|vol| filenames << build_workbook(vol) }

#set the output, and return to C#
self.callerOutput=filenames