Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import pandas as pd
|
|
5 |
import time
|
6 |
import random
|
7 |
from datetime import datetime
|
|
|
8 |
|
9 |
# Set page configuration
|
10 |
st.set_page_config(
|
@@ -275,30 +276,14 @@ if df is not None and not df.empty:
|
|
275 |
# Display the data
|
276 |
st.dataframe(filtered_df, use_container_width=True)
|
277 |
|
278 |
-
# Download
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
mime="text/csv",
|
287 |
-
)
|
288 |
-
with col2:
|
289 |
-
excel_buffer = pd.ExcelWriter("twse_announcements.xlsx", engine='xlsxwriter')
|
290 |
-
filtered_df.to_excel(excel_buffer, index=False, sheet_name='公告資料')
|
291 |
-
excel_buffer.close()
|
292 |
-
|
293 |
-
with open("twse_announcements.xlsx", "rb") as f:
|
294 |
-
excel_data = f.read()
|
295 |
-
|
296 |
-
st.download_button(
|
297 |
-
label="下載為Excel",
|
298 |
-
data=excel_data,
|
299 |
-
file_name="twse_announcements.xlsx",
|
300 |
-
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
301 |
-
)
|
302 |
|
303 |
# Display statistics
|
304 |
st.subheader("資料統計")
|
@@ -367,5 +352,5 @@ with st.expander("常見問題", expanded=False):
|
|
367 |
|
368 |
# Add version info
|
369 |
st.sidebar.markdown("---")
|
370 |
-
st.sidebar.caption("版本: 1.1.
|
371 |
st.sidebar.caption("最後更新: 2025-04-01")
|
|
|
5 |
import time
|
6 |
import random
|
7 |
from datetime import datetime
|
8 |
+
import io
|
9 |
|
10 |
# Set page configuration
|
11 |
st.set_page_config(
|
|
|
276 |
# Display the data
|
277 |
st.dataframe(filtered_df, use_container_width=True)
|
278 |
|
279 |
+
# Download as CSV
|
280 |
+
csv = filtered_df.to_csv(index=False).encode('utf-8-sig')
|
281 |
+
st.download_button(
|
282 |
+
label="下載為CSV",
|
283 |
+
data=csv,
|
284 |
+
file_name="twse_announcements.csv",
|
285 |
+
mime="text/csv",
|
286 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
|
288 |
# Display statistics
|
289 |
st.subheader("資料統計")
|
|
|
352 |
|
353 |
# Add version info
|
354 |
st.sidebar.markdown("---")
|
355 |
+
st.sidebar.caption("版本: 1.1.1")
|
356 |
st.sidebar.caption("最後更新: 2025-04-01")
|