diff --git a/deps.edn b/deps.edn
index 0d68f671a9b353eb5bb9974d8daa767862b62a5a..666471da1bae0724f55c2ad5decb6c2e40c9a003 100644
--- a/deps.edn
+++ b/deps.edn
@@ -125,6 +125,7 @@
   org.apache.poi/poi-ooxml                  {:mvn/version "5.2.5"
                                              :exclusions  [org.bouncycastle/bcpkix-jdk15on
                                                            org.bouncycastle/bcprov-jdk15on]}
+  org.apache.poi/poi-ooxml-full             {:mvn/version "5.2.5"}
   org.apache.sshd/sshd-core                 {:mvn/version "2.12.1"              ; ssh tunneling and test server
                                              :exclusions  [org.slf4j/slf4j-api
                                                            org.slf4j/jcl-over-slf4j]}
diff --git a/src/metabase/query_processor/streaming/xlsx.clj b/src/metabase/query_processor/streaming/xlsx.clj
index 23acb6c64f8f3f7318997c8da663ac2e1c7bfc67..8e81cd6b385684b37a2d4e56c65b769a92367833 100644
--- a/src/metabase/query_processor/streaming/xlsx.clj
+++ b/src/metabase/query_processor/streaming/xlsx.clj
@@ -25,7 +25,8 @@
    (org.apache.poi.ss.usermodel Cell DataConsolidateFunction DataFormat DateUtil Workbook)
    (org.apache.poi.ss.util AreaReference CellRangeAddress CellReference)
    (org.apache.poi.xssf.streaming SXSSFRow SXSSFSheet SXSSFWorkbook)
-   (org.apache.poi.xssf.usermodel XSSFPivotTable XSSFRow XSSFSheet XSSFWorkbook)))
+   (org.apache.poi.xssf.usermodel XSSFPivotTable XSSFRow XSSFSheet XSSFWorkbook)
+   (org.openxmlformats.schemas.spreadsheetml.x2006.main STFieldSortType)))
 
 (set! *warn-on-reflection* true)
 
@@ -576,7 +577,7 @@
 ;; Since we're the ones creating the file, we can lower the ratio to get what we want.
 (ZipSecureFile/setMinInflateRatio 0.001)
 (defn- init-native-pivot
-  [{:keys [pivot-grouping-key] :as pivot-spec}
+  [{:keys [pivot-grouping-key column-sort-order] :as pivot-spec}
    {:keys [ordered-cols col-settings viz-settings format-rows?]}]
   (let [idx-shift                   (fn [indices]
                                       (map (fn [idx]
@@ -612,6 +613,16 @@
       (.addColLabel pivot-table idx))
     (doseq [idx pivot-measures]
       (.addColumnLabel pivot-table DataConsolidateFunction/SUM #_(get aggregation-functions idx DataConsolidateFunction/SUM) idx))
+    (doseq [[idx sort-setting] column-sort-order]
+      (let [setting (case sort-setting
+                      :ascending STFieldSortType/ASCENDING
+                      :descending STFieldSortType/DESCENDING)]
+        (when setting
+          (-> pivot-table
+              .getCTPivotTableDefinition
+              .getPivotFields
+              (.getPivotFieldArray idx)
+              (.setSortType setting)))))
     (let [swb   (-> (SXSSFWorkbook. ^XSSFWorkbook wb)
                     (doto (.setCompressTempFiles true)))
           sheet (spreadsheet/select-sheet "data" swb)]