#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  Sheet_addition_test.py
#  
#  Copyright 2015 Ulrich Brammer <ulrich@Pauline>
#  
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#  
#  

theDoc = App.newDocument("SheetTest")
App.setActiveDocument("SheetTest")
#App.activeDocument("SheetTest")


p=App.ParamGet("User parameter:BaseApp/Preferences/General")
thePath = p.GetString('FileOpenSavePath')


mySheet = theDoc.addObject('Spreadsheet::Sheet','Spreadsheet')

mySheet.set('A1', '1')
mySheet.set('A2', '2')
theDoc.recompute()
mySheet.set('A3', '=A1+A2')
mySheet.setPosition('A4')
#theDoc.saveAs("/home/ulrich/FreeCAD/Spreadsheet/Sheet_4.fcstd")
theDoc.saveAs(thePath + '/Sheet_5.fcstd')
mySheet.set('A4', '=A3')
theDoc.recompute()

if mySheet.State == ['Invalid']:
  print "Invalid Spreadsheet"
else:
  print "No error found"




def main():
	
	return 0

if __name__ == '__main__':
	main()

