pridane export body
This commit is contained in:
parent
00ab98c9cc
commit
503d7724b4
Binary file not shown.
|
|
@ -0,0 +1,14 @@
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
|
||||||
|
df = pd.read_excel('body_easy.xlsx', sheet_name='List1')
|
||||||
|
|
||||||
|
|
||||||
|
df_deduplicated = df.drop_duplicates(subset=['Název'], keep='first')
|
||||||
|
|
||||||
|
df_final = pd.concat([df, df_deduplicated]).sort_values(by=['x', 'y'])
|
||||||
|
df_final = df_final['Název'].reset_index(drop=True)
|
||||||
|
|
||||||
|
|
||||||
|
print(df_final)
|
||||||
|
df_final.to_excel('body_easy_exported.xlsx', sheet_name='List1', index=False, header=False)
|
||||||
|
|
@ -7,8 +7,14 @@ importlib-metadata==8.5.0
|
||||||
itsdangerous==2.2.0
|
itsdangerous==2.2.0
|
||||||
jinja2==3.1.6
|
jinja2==3.1.6
|
||||||
markupsafe==2.1.5
|
markupsafe==2.1.5
|
||||||
|
numpy==1.24.4
|
||||||
openpyxl==3.1.5
|
openpyxl==3.1.5
|
||||||
|
pandas==2.0.3
|
||||||
pyparsing==3.1.4
|
pyparsing==3.1.4
|
||||||
|
python-dateutil==2.9.0.post0
|
||||||
|
pytz==2025.2
|
||||||
|
six==1.17.0
|
||||||
typing-extensions==4.13.2
|
typing-extensions==4.13.2
|
||||||
|
tzdata==2025.2
|
||||||
werkzeug==3.0.6
|
werkzeug==3.0.6
|
||||||
zipp==3.20.2
|
zipp==3.20.2
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
@ -11,10 +12,17 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header class="container"><h1>XLSX to DXF Converter</h1></header>
|
<header class="container">
|
||||||
|
<h1>XLSX to DXF Converter</h1>
|
||||||
|
</header>
|
||||||
<main class="container">
|
<main class="container">
|
||||||
|
|
||||||
<form action="" method="post" enctype="multipart/form-data">
|
<form action="" method="post" enctype="multipart/form-data">
|
||||||
<input type="file" id="file-input" name="file" accept=".xls, .csv, .xlsx" required>
|
<input type="file" id="file-input" name="file" accept=".xls, .csv, .xlsx" required>
|
||||||
|
<hr>
|
||||||
|
<div class="grid">
|
||||||
|
<div>
|
||||||
|
|
||||||
|
|
||||||
<div class="grid">
|
<div class="grid">
|
||||||
<label for="range">Velikost textu
|
<label for="range">Velikost textu
|
||||||
|
|
@ -24,9 +32,34 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label for="file-name">Název výstupního DXF</label>
|
<label for="file-name">Název výstupního DXF</label>
|
||||||
<input type="text" id="file-name" name="output_file" placeholder="název výstupního DXF:" value="vystupni_body">
|
<input type="text" id="file-name" name="output_file" placeholder="název výstupního DXF:"
|
||||||
|
value="vystupni_body">
|
||||||
|
|
||||||
<input type="submit" id="submit-button" value="Nahrát a stáhnout hotový">
|
<button name="btn" type="submit" id="submit-button" value="dxf">Nahrát a stáhnout DXF</button>
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="range">Štítky nachystat pro:
|
||||||
|
</label>
|
||||||
|
<select id="select" name="select" required>
|
||||||
|
<option value="0" selected>praváka</option>
|
||||||
|
<option value="1">leváka</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<label for="file-name">Název souboru s popisky</label>
|
||||||
|
<input type="text" id="file-name" name="excel_output_file" placeholder="název výstupního DXF:"
|
||||||
|
value="popisy_vystup">
|
||||||
|
|
||||||
|
<button name="btn" id="excel-download" type="submit" value="excel">Nahrát a stáhnout
|
||||||
|
popisky</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
|
|
@ -37,6 +70,14 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
#excel-download {
|
||||||
|
background-color: #34C759;
|
||||||
|
/* green background */
|
||||||
|
color: #033009;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#font_size {
|
#font_size {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
|
@ -46,4 +87,3 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
|
||||||
42
test.py
42
test.py
|
|
@ -1,9 +1,10 @@
|
||||||
from flask import Flask, request, render_template, send_file
|
from flask import Flask, request, render_template, send_file, make_response
|
||||||
from io import BytesIO, StringIO
|
from io import BytesIO, StringIO
|
||||||
import ezdxf
|
import ezdxf
|
||||||
import openpyxl
|
import openpyxl
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
@ -11,6 +12,7 @@ app = Flask(__name__)
|
||||||
def upload_file():
|
def upload_file():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
file = request.files['file']
|
file = request.files['file']
|
||||||
|
if request.form['btn'] == 'dxf':
|
||||||
if file.filename.endswith('.xls') or file.filename.endswith('.csv') or file.filename.endswith('.xlsx'):
|
if file.filename.endswith('.xls') or file.filename.endswith('.csv') or file.filename.endswith('.xlsx'):
|
||||||
# Create a text file with the uploaded file name
|
# Create a text file with the uploaded file name
|
||||||
|
|
||||||
|
|
@ -31,8 +33,44 @@ def upload_file():
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return render_template('upload_form.html', no_file=True)
|
return render_template('upload_form.html', no_file=True)
|
||||||
|
else:
|
||||||
|
# Generate the download file
|
||||||
|
file_data = BytesIO(b"necum")
|
||||||
|
file_name = request.form['excel_output_file']
|
||||||
|
|
||||||
|
|
||||||
|
df = pd.read_excel(file, sheet_name='List1')
|
||||||
|
|
||||||
|
|
||||||
|
df_deduplicated = df.drop_duplicates(subset=['Název'], keep='first')
|
||||||
|
|
||||||
|
df_final = pd.concat([df, df_deduplicated]).sort_values(by=['x', 'y'], ascending=request.form.get('select')== '1')
|
||||||
|
df_final = df_final['Název'].reset_index(drop=True)
|
||||||
|
|
||||||
|
|
||||||
|
df_final.to_excel(file_data, sheet_name='List1', index=False, header=False)
|
||||||
|
file_data.seek(0)
|
||||||
|
|
||||||
|
return send_file(
|
||||||
|
path_or_file=file_data,
|
||||||
|
as_attachment=True,
|
||||||
|
download_name= file_name+".xlsx" or 'hotovson.xlsx',
|
||||||
|
mimetype='application/octet-stream'
|
||||||
|
)
|
||||||
|
|
||||||
return render_template('upload_form.html')
|
return render_template('upload_form.html')
|
||||||
|
|
||||||
|
@app.route('/excel_labels', methods=['GET', 'POST'])
|
||||||
|
def excel_labels():
|
||||||
|
|
||||||
|
# Generate the download file
|
||||||
|
file_data = BytesIO(b"necum")
|
||||||
|
file_name = 'download_file.xlsx'
|
||||||
|
|
||||||
|
response = make_response(send_file(file_data, mimetype='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'))
|
||||||
|
response.headers['Content-Disposition'] = f'attachment; {file_name}'
|
||||||
|
return response
|
||||||
|
|
||||||
def nacti_data_z_excelu(soubor, listname="List1"):
|
def nacti_data_z_excelu(soubor, listname="List1"):
|
||||||
wb = openpyxl.load_workbook(soubor, data_only=True)
|
wb = openpyxl.load_workbook(soubor, data_only=True)
|
||||||
sheet = wb[listname]
|
sheet = wb[listname]
|
||||||
|
|
@ -76,4 +114,4 @@ def exportuj_do_dxf(body, velikost) -> BytesIO:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=False, port=5003, host='0.0.0.0')
|
app.run(debug=True, port=5003, host='0.0.0.0')
|
||||||
Loading…
Reference in New Issue