# -*- encoding: utf-8 -*-
#
# Author: Massimo Menichinelli
# Homepage: http://www.openp2pdesign.org
# License: MIT
#

import xlsxwriter

# Create document -------------------------------------------------------------

# Create the file
workbook = xlsxwriter.Workbook('FabLab-BusinessPlan.xlsx')

# Create the worksheets
expenses = workbook.add_worksheet('Expenses')
activities = workbook.add_worksheet('Activities')
membership = workbook.add_worksheet('Membership')
total = workbook.add_worksheet('Total')


# Create styles -------------------------------------------------------------

# Add a bold style to highlight heading cells
bold_style = workbook.add_format()
bold_style.set_font_color('white')
bold_style.set_bg_color('F56A2F')
bold_style.set_bold()

# Add a total style to highlight total cells
total_style = workbook.add_format()
total_style.set_font_color('red')
total_style.set_bg_color('FAECC5')
total_style.set_bold()

# Add a style for money
money_style = workbook.add_format()
money_style.set_num_format('$ 0.00')

# Add a style for money totals
money_total_style = workbook.add_format()
# Add green/red color for positive/negative numbers
money_total_style.set_num_format('[Green]$ 0.00;[Red]$ -0.00;$ 0.00')
total_style.set_bg_color('FAECC5')


# Add content -------------------------------------------------------------

# Dummy values
item_value = 0.00

# Set the width of the columns
expenses.set_column('A:A', 10)

# Add content to the Expenses worksheet
expenses.write('A1', 'Hello world', bold_style)
expenses.write('A2', item_value, money_style)
expenses.write('A3', item_value, money_style)
expenses.write('A4', '=SUM(A2:A3)', money_total_style)


# Save document -------------------------------------------------------------

# Save and close the file
workbook.close()

# Open the file in OSX, for debug
import subprocess
import os
where = os.path.dirname(os.path.abspath(__file__))
subprocess.check_output(["./soffice",where+"/FabLab-BusinessPlan.xlsx"], cwd="/Applications/LibreOffice.app/Contents/MacOS")
@@ -315,22 +315,23 @@
 heets%0Aex
-penses
+ecutive
  = workb
@@ -355,27 +355,33 @@
 ('Ex
-penses')%0Aactivities
+ecutive Summary')%0Acompany
  = w
@@ -407,31 +407,32 @@
 et('
-Activities')%0Amembership
+Company Summary')%0Amarket
  = w
@@ -459,25 +459,154 @@
 t('M
-embership')%0Atotal
+arket Analysis')%0A%0A#%C2%A0Add a worksheet for each year%0Astarting_year = 2015%0Ayears_number = 5%0Ayears = %7B%7D%0Afor i in range(years_number):%0A    years%5B2015+i%5D
  = w
@@ -632,14 +632,30 @@
 et('
-Total'
+Plan for '+str(2015+i)
 )%0A%0A%0A
@@ -1554,22 +1554,23 @@
 lumns%0Aex
-penses
+ecutive
 .set_col
@@ -1627,22 +1627,23 @@
 sheet%0Aex
-penses
+ecutive
 .write('
@@ -1668,38 +1668,39 @@
 , bold_style)%0Aex
-penses
+ecutive
 .write('A2', ite
@@ -1715,38 +1715,39 @@
  money_style)%0Aex
-penses
+ecutive
 .write('A3', ite
@@ -1770,22 +1770,23 @@
 tyle)%0Aex
-penses
+ecutive
 .write('
@@ -1825,16 +1825,478 @@
 style)%0A%0A
+#%C2%A0Notes for the structure:%0A%0A#%C2%A0Executive summary%0A#%C2%A0Introduction%0A#%C2%A0Bar chart for years%0A#%C2%A0Objectives%0A#%C2%A0Mission%0A#%C2%A0Keys to success%0A%0A#%C2%A0Company summary%0A# Company structure/ownership%0A#%C2%A0Start-up summary%0A#%C2%A0Bar chart for start-up costs%0A%0A#%C2%A0Market analysis%0A#%C2%A0Market segmentation%0A#%C2%A0Pie chart for market segmentation%0A#%C2%A0Target Market Segment Strategy%0A%0A#%C2%A0Strategy%0A#%C2%A0Communication%0A#%C2%A0Years forecast%0A#%C2%A0Chart years forecast%0A%0A#%C2%A0Management%0A#%C2%A0Persons%0A#%C2%A0Years forecast%0A%0A#%C2%A0Financial plan%0A
 %0A#%C2%A0Save 

Rearrange structure of worksheets with notes