An image forming apparatus having a direct print function by which application data is obtained from an external device so that image formation is performed, the application data including SpreadsheetML data having a hierarchical structure having a plurality of levels, the image forming apparatus comprising: an obtaining unit configured to obtain the SpreadsheetML data; a classification unit configured to classify the SpreadsheetML data into use data used for the image formation and no-use data not used for the image formation on the basis of a predetermined setting related to the image formation, wherein the classification unit classifies the SpreadsheetML data so as to classify each partial data of the SpreadsheetML data as the use data or the non-use data on the basis of a header for the partial data; a discarding unit configured to discard the no-use data, wherein the discarding unit discards a packet corresponding to the partial data classified as the no-use data; a storage unit configured to store the predetermined setting related to the image formation in advance, the storage unit being further configured to store the use data classified by the classification unit; an image processing unit configured to generate print data on the basis of the stored use data; and an image forming unit configured to perform the image formation on the basis of the print data; wherein the predetermined setting related to the image formation includes a setting item related to a decision as to which sheet of the SpreadsheetML data is a subject for image formation, so as to set one of a current sheet printing mode for printing only a sheet being displayed at the most front when an information processing apparatus such as a PC opens the SpreadsheetML data and a whole workbook printing mode for printing a whole workbook of the SpreadsheetML data; wherein when the current sheet printing mode is set as the predetermined setting related to the image formation for the SpreadsheetML data, a local file header having a number for a sheet other than the current sheet is discarded, and a local file element for the number is discarded. an obtaining unit configured to obtain the SpreadsheetML data; a classification unit configured to classify the SpreadsheetML data into use data used for the image formation and no-use data not used for the image formation on the basis of a predetermined setting related to the image formation, wherein the classification unit classifies the SpreadsheetML data so as to classify each partial data of the SpreadsheetML data as the use data or the non-use data on the basis of a header for the partial data; a discarding unit configured to discard the no-use data, wherein the discarding unit discards a packet corresponding to the partial data classified as the no-use data; a storage unit configured to store the predetermined setting related to the image formation in advance, the storage unit being further configured to store the use data classified by the classification unit; an image processing unit configured to generate print data on the basis of the stored use data; and an image forming unit configured to perform the image formation on the basis of the print data; wherein the predetermined setting related to the image formation includes a setting item related to a decision as to which sheet of the SpreadsheetML data is a subject for image formation, so as to set one of a current sheet printing mode for printing only a sheet being displayed at the most front when an information processing apparatus such as a PC opens the SpreadsheetML data and a whole workbook printing mode for printing a whole workbook of the SpreadsheetML data; wherein when the current sheet printing mode is set as the predetermined setting related to the image formation for the SpreadsheetML data, a local file header having a number for a sheet other than the current sheet is discarded, and a local file element for the number is discarded.